[java-shib-shared] branch main updated: Extend Jetty class with additional constructors.

Codeberg noreply at shibboleth.net
Thu Jul 9 16:19:26 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository java-shib-shared.

View the commit online:
https://codeberg.org/Shibboleth/java-shib-shared/commit/f3cfc8d7601ec152edb37766057853fef4d1f677

The following commit(s) were added to refs/heads/main by this push:
     new f3cfc8d7 Extend Jetty class with additional constructors.
f3cfc8d7 is described below

commit f3cfc8d7601ec152edb37766057853fef4d1f677
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Thu Jul 9 12:19:12 2026 -0400

    Extend Jetty class with additional constructors.
---
 .../shibboleth/shared/testing/EmbeddedJetty.java   | 46 +++++++++++++++++++---
 1 file changed, 40 insertions(+), 6 deletions(-)

diff --git a/shib-testing/src/main/java/net/shibboleth/shared/testing/EmbeddedJetty.java b/shib-testing/src/main/java/net/shibboleth/shared/testing/EmbeddedJetty.java
index 83ae0bb7..db6ecef2 100644
--- a/shib-testing/src/main/java/net/shibboleth/shared/testing/EmbeddedJetty.java
+++ b/shib-testing/src/main/java/net/shibboleth/shared/testing/EmbeddedJetty.java
@@ -46,6 +46,7 @@ import org.springframework.core.io.ClassPathResource;
 
 import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.NonnullSupplier;
 import net.shibboleth.shared.resource.Resource;
 import net.shibboleth.shared.spring.resource.ResourceHelper;
 
@@ -193,9 +194,9 @@ public class EmbeddedJetty implements Closeable {
      */
     public static class ResourceHandler extends Handler.Abstract {
 
-        final int status;
+        @Nonnull final NonnullSupplier<Integer> statusSupplier;
         
-        @Nonnull final Resource resource;
+        @Nonnull final NonnullSupplier<Resource> resourceSupplier;
         
         @Nullable String contentType;
 
@@ -206,8 +207,41 @@ public class EmbeddedJetty implements Closeable {
          * @param r resource to serve
          */
         public ResourceHandler(final int s, @Nonnull final Resource r) {
-            status = s;
-            resource = Constraint.isNotNull(r, "Resource cannot be null");
+            statusSupplier = NonnullSupplier.of(s);
+            resourceSupplier = NonnullSupplier.of(Constraint.isNotNull(r, "Resource cannot be null"));
+        }
+        
+        /**
+         * Constructor.
+         * 
+         * <p>Uses 200 as the status.</p>
+         *
+         * @param r resource to serve
+         */
+        public ResourceHandler(@Nonnull final Resource r) {
+            this(200, r);
+        }
+        
+        /**
+         * Constructor.
+         *
+         * @param s status supplier
+         * @param r resource supplier
+         */
+        public ResourceHandler(@Nonnull final NonnullSupplier<Integer> s, @Nonnull final NonnullSupplier<Resource> r) {
+            statusSupplier = Constraint.isNotNull(s, "Status supplier cannot be null");
+            resourceSupplier = Constraint.isNotNull(r, "Resource supplier cannot be null");
+        }
+
+        /**
+         * Constructor.
+         * 
+         * <p>Uses 200 as the status.</p>
+         * 
+         * @param r resource supplier
+         */
+        public ResourceHandler(@Nonnull final NonnullSupplier<Resource> r) {
+            this(NonnullSupplier.of(200), r);
         }
         
         /**
@@ -225,8 +259,8 @@ public class EmbeddedJetty implements Closeable {
             if (contentType != null) {
                 response.getHeaders().add("Content-Type", contentType);
             }
-            response.setStatus(status);
-            response.write(true, ByteBuffer.wrap(resource.getInputStream().readAllBytes()), callback);
+            response.setStatus(statusSupplier.get());
+            response.write(true, ByteBuffer.wrap(resourceSupplier.get().getInputStream().readAllBytes()), callback);
             return true;
         }
     }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list