Merge pull request #5180 from jansupol/j2.38.merge.1
Merge remote-tracking branch 'MSTR/master' into 3.0.x branch
diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/SslFilterTLS13Test.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/SslFilterTLS13Test.java
index 757b834..aff6033 100644
--- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/SslFilterTLS13Test.java
+++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/SslFilterTLS13Test.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,11 +16,30 @@
package org.glassfish.jersey.jdk.connector.internal;
+import java.util.Arrays;
+
+import javax.net.ssl.SSLContext;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
public class SslFilterTLS13Test extends SslFilterTest {
- public SslFilterTLS13Test() {
- System.setProperty("jdk.tls.server.protocols", "TLSv1.3");
- System.setProperty("jdk.tls.client.protocols", "TLSv1.3");
+ @BeforeClass
+ public static void setup() throws Exception {
+ final SSLContext context = SSLContext.getInstance("TLS");
+ context.init(null, null, null);
+ final String[] supportedProtocols = context.getDefaultSSLParameters().getProtocols();
+ if (Arrays.toString(supportedProtocols).contains("TLSv1.3")) {
+ System.setProperty("jdk.tls.server.protocols", "TLSv1.3");
+ System.setProperty("jdk.tls.client.protocols", "TLSv1.3");
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ System.clearProperty("jdk.tls.server.protocols");
+ System.clearProperty("jdk.tls.client.protocols");
}
}
diff --git a/containers/grizzly2-http/src/main/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpContainer.java b/containers/grizzly2-http/src/main/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpContainer.java
index 686f50f..d0f65c3 100644
--- a/containers/grizzly2-http/src/main/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpContainer.java
+++ b/containers/grizzly2-http/src/main/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpContainer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -370,7 +370,7 @@
@Override
public void reload() {
- reload(appHandler.getConfiguration());
+ reload(new ResourceConfig(appHandler.getConfiguration()));
}
@Override
diff --git a/containers/jdk-http/src/main/java/org/glassfish/jersey/jdkhttp/JdkHttpHandlerContainer.java b/containers/jdk-http/src/main/java/org/glassfish/jersey/jdkhttp/JdkHttpHandlerContainer.java
index 89f47d2..1470f22 100644
--- a/containers/jdk-http/src/main/java/org/glassfish/jersey/jdkhttp/JdkHttpHandlerContainer.java
+++ b/containers/jdk-http/src/main/java/org/glassfish/jersey/jdkhttp/JdkHttpHandlerContainer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -201,7 +201,7 @@
@Override
public void reload() {
- reload(getConfiguration());
+ reload(new ResourceConfig(getConfiguration()));
}
@Override
diff --git a/containers/jdk-http/src/main/java/org/glassfish/jersey/jdkhttp/JdkHttpServerFactory.java b/containers/jdk-http/src/main/java/org/glassfish/jersey/jdkhttp/JdkHttpServerFactory.java
index 1c60336..9b5f8b7 100644
--- a/containers/jdk-http/src/main/java/org/glassfish/jersey/jdkhttp/JdkHttpServerFactory.java
+++ b/containers/jdk-http/src/main/java/org/glassfish/jersey/jdkhttp/JdkHttpServerFactory.java
@@ -227,11 +227,15 @@
? (isHttp ? Container.DEFAULT_HTTP_PORT : Container.DEFAULT_HTTPS_PORT)
: uri.getPort();
+ final InetSocketAddress socketAddress = (uri.getHost() == null)
+ ? new InetSocketAddress(port)
+ : new InetSocketAddress(uri.getHost(), port);
+
final HttpServer server;
try {
server = isHttp
- ? HttpServer.create(new InetSocketAddress(port), 0)
- : HttpsServer.create(new InetSocketAddress(port), 0);
+ ? HttpServer.create(socketAddress, 0)
+ : HttpsServer.create(socketAddress, 0);
} catch (final IOException ioe) {
throw new ProcessingException(LocalizationMessages.ERROR_CONTAINER_EXCEPTION_IO(), ioe);
}
diff --git a/containers/jersey-servlet-core/src/main/java/org/glassfish/jersey/servlet/ServletContainer.java b/containers/jersey-servlet-core/src/main/java/org/glassfish/jersey/servlet/ServletContainer.java
index d91c43a..13702a9 100644
--- a/containers/jersey-servlet-core/src/main/java/org/glassfish/jersey/servlet/ServletContainer.java
+++ b/containers/jersey-servlet-core/src/main/java/org/glassfish/jersey/servlet/ServletContainer.java
@@ -640,7 +640,7 @@
@Override
public void reload() {
- reload(getConfiguration());
+ reload(new ResourceConfig(getConfiguration()));
}
@Override
diff --git a/containers/jetty-http/src/main/java11/org/glassfish/jersey/jetty/JettyHttpContainer.java b/containers/jetty-http/src/main/java11/org/glassfish/jersey/jetty/JettyHttpContainer.java
index 26ccd92..183fd0f 100644
--- a/containers/jetty-http/src/main/java11/org/glassfish/jersey/jetty/JettyHttpContainer.java
+++ b/containers/jetty-http/src/main/java11/org/glassfish/jersey/jetty/JettyHttpContainer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -427,7 +427,7 @@
@Override
public void reload() {
- reload(getConfiguration());
+ reload(new ResourceConfig(getConfiguration()));
}
@Override
diff --git a/containers/netty-http/src/main/java/org/glassfish/jersey/netty/httpserver/NettyHttpContainer.java b/containers/netty-http/src/main/java/org/glassfish/jersey/netty/httpserver/NettyHttpContainer.java
index bbbb5dc..cbd7fe4 100644
--- a/containers/netty-http/src/main/java/org/glassfish/jersey/netty/httpserver/NettyHttpContainer.java
+++ b/containers/netty-http/src/main/java/org/glassfish/jersey/netty/httpserver/NettyHttpContainer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -53,7 +53,7 @@
@Override
public void reload() {
- reload(appHandler.getConfiguration());
+ reload(new ResourceConfig(appHandler.getConfiguration()));
}
@Override
diff --git a/containers/simple-http/src/main/java/org/glassfish/jersey/simple/SimpleContainer.java b/containers/simple-http/src/main/java/org/glassfish/jersey/simple/SimpleContainer.java
index 327b2cf..afd86b5 100644
--- a/containers/simple-http/src/main/java/org/glassfish/jersey/simple/SimpleContainer.java
+++ b/containers/simple-http/src/main/java/org/glassfish/jersey/simple/SimpleContainer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -407,7 +407,7 @@
@Override
public void reload() {
- reload(getConfiguration());
+ reload(new ResourceConfig(getConfiguration()));
}
@Override
diff --git a/core-common/src/main/java/org/glassfish/jersey/internal/inject/InjectionManager.java b/core-common/src/main/java/org/glassfish/jersey/internal/inject/InjectionManager.java
index 36fc610..4d5fd1c 100644
--- a/core-common/src/main/java/org/glassfish/jersey/internal/inject/InjectionManager.java
+++ b/core-common/src/main/java/org/glassfish/jersey/internal/inject/InjectionManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -51,6 +51,12 @@
void shutdown();
/**
+ * Returns {@code true} when the {@link InjectionManager} has been shutdown, {@code false} otherwise.
+ * @return Whether the {@code InjectionManager} has been shutdown.
+ */
+ boolean isShutdown();
+
+ /**
* Registers one bean represented using fields in the provided descriptor. The final bean can be direct bean or
* factory object which will create the bean at the time of injection. {@code InjectionManager} is able to register a bean
* represented by a class or direct instance.
diff --git a/core-common/src/main/java/org/glassfish/jersey/message/internal/MessagingBinders.java b/core-common/src/main/java/org/glassfish/jersey/message/internal/MessagingBinders.java
index e6ce303..fa1117a 100644
--- a/core-common/src/main/java/org/glassfish/jersey/message/internal/MessagingBinders.java
+++ b/core-common/src/main/java/org/glassfish/jersey/message/internal/MessagingBinders.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,11 +17,13 @@
package org.glassfish.jersey.message.internal;
import java.security.AccessController;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
import jakarta.ws.rs.RuntimeType;
@@ -48,6 +50,14 @@
public final class MessagingBinders {
private static final Logger LOGGER = Logger.getLogger(MessagingBinders.class.getName());
+ private static final Map<EnabledProvidersBinder.Provider, AtomicBoolean> warningMap;
+
+ static {
+ warningMap = new HashMap<>();
+ for (EnabledProvidersBinder.Provider provider : EnabledProvidersBinder.Provider.values()) {
+ warningMap.put(provider, new AtomicBoolean(false));
+ }
+ }
/**
* Prevents instantiation.
@@ -223,21 +233,23 @@
}
providerBinder.bind(binder, provider);
} else {
- switch (provider) {
- case DOMSOURCE:
- case SAXSOURCE:
- case STREAMSOURCE:
- LOGGER.warning(LocalizationMessages.DEPENDENT_CLASS_OF_DEFAULT_PROVIDER_NOT_FOUND(provider.className,
- "MessageBodyReader<" + provider.className + ">")
- );
- break;
- case DATASOURCE:
- case RENDEREDIMAGE:
- case SOURCE:
- LOGGER.warning(LocalizationMessages.DEPENDENT_CLASS_OF_DEFAULT_PROVIDER_NOT_FOUND(provider.className,
- "MessageBodyWriter<" + provider.className + ">")
- );
- break;
+ if (warningMap.get(provider).compareAndSet(false, true)) {
+ switch (provider) {
+ case DOMSOURCE:
+ case SAXSOURCE:
+ case STREAMSOURCE:
+ LOGGER.warning(LocalizationMessages.DEPENDENT_CLASS_OF_DEFAULT_PROVIDER_NOT_FOUND(
+ provider.className, "MessageBodyReader<" + provider.className + ">")
+ );
+ break;
+ case DATASOURCE:
+ case RENDEREDIMAGE:
+ case SOURCE:
+ LOGGER.warning(LocalizationMessages.DEPENDENT_CLASS_OF_DEFAULT_PROVIDER_NOT_FOUND(
+ provider.className, "MessageBodyWriter<" + provider.className + ">")
+ );
+ break;
+ }
}
}
}
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java
index 0654582..3dd95b3 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java
@@ -85,6 +85,17 @@
}
/**
+ * The annotation visitor to which this visitor must delegate method calls. May be {@literal
+ * null}.
+ *
+ * @return the annotation visitor to which this visitor must delegate method calls, or {@literal
+ * null}.
+ */
+ public AnnotationVisitor getDelegate() {
+ return av;
+ }
+
+ /**
* Visits a primitive value of the annotation.
*
* @param name the value name.
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java
index bd090e6..f63fc71 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java
@@ -28,7 +28,7 @@
package jersey.repackaged.org.objectweb.asm;
/**
- * A non standard class, field, method or code attribute, as defined in the Java Virtual Machine
+ * A non standard class, field, method or Code attribute, as defined in the Java Virtual Machine
* Specification (JVMS).
*
* @see <a href= "https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7">JVMS
@@ -52,7 +52,7 @@
/**
* The next attribute in this attribute list (Attribute instances can be linked via this field to
- * store a list of class, field, method or code attributes). May be {@literal null}.
+ * store a list of class, field, method or Code attributes). May be {@literal null}.
*/
Attribute nextAttribute;
@@ -80,9 +80,9 @@
}
/**
- * Returns {@literal true} if this type of attribute is a code attribute.
+ * Returns {@literal true} if this type of attribute is a Code attribute.
*
- * @return {@literal true} if this type of attribute is a code attribute.
+ * @return {@literal true} if this type of attribute is a Code attribute.
*/
public boolean isCodeAttribute() {
return false;
@@ -92,7 +92,7 @@
* Returns the labels corresponding to this attribute.
*
* @return the labels corresponding to this attribute, or {@literal null} if this attribute is not
- * a code attribute that contains labels.
+ * a Code attribute that contains labels.
*/
protected Label[] getLabels() {
return new Label[0];
@@ -111,11 +111,11 @@
* @param charBuffer the buffer to be used to call the ClassReader methods requiring a
* 'charBuffer' parameter.
* @param codeAttributeOffset index of the first byte of content of the enclosing Code attribute
- * in {@link ClassReader}, or -1 if the attribute to be read is not a code attribute. The 6
+ * in {@link ClassReader}, or -1 if the attribute to be read is not a Code attribute. The 6
* attribute header bytes (attribute_name_index and attribute_length) are not taken into
* account here.
* @param labels the labels of the method's code, or {@literal null} if the attribute to be read
- * is not a code attribute.
+ * is not a Code attribute.
* @return a <i>new</i> {@link Attribute} object corresponding to the specified bytes.
*/
protected Attribute read(
@@ -138,16 +138,16 @@
*
* @param classWriter the class to which this attribute must be added. This parameter can be used
* to add the items that corresponds to this attribute to the constant pool of this class.
- * @param code the bytecode of the method corresponding to this code attribute, or {@literal null}
- * if this attribute is not a code attribute. Corresponds to the 'code' field of the Code
+ * @param code the bytecode of the method corresponding to this Code attribute, or {@literal null}
+ * if this attribute is not a Code attribute. Corresponds to the 'code' field of the Code
* attribute.
* @param codeLength the length of the bytecode of the method corresponding to this code
- * attribute, or 0 if this attribute is not a code attribute. Corresponds to the 'code_length'
+ * attribute, or 0 if this attribute is not a Code attribute. Corresponds to the 'code_length'
* field of the Code attribute.
- * @param maxStack the maximum stack size of the method corresponding to this code attribute, or
- * -1 if this attribute is not a code attribute.
+ * @param maxStack the maximum stack size of the method corresponding to this Code attribute, or
+ * -1 if this attribute is not a Code attribute.
* @param maxLocals the maximum number of local variables of the method corresponding to this code
- * attribute, or -1 if this attribute is not a code attribute.
+ * attribute, or -1 if this attribute is not a Code attribute.
* @return the byte array form of this attribute.
*/
protected ByteVector write(
@@ -197,16 +197,16 @@
* attribute_length) per attribute. Also adds the attribute type names to the constant pool.
*
* @param symbolTable where the constants used in the attributes must be stored.
- * @param code the bytecode of the method corresponding to these code attributes, or {@literal
- * null} if they are not code attributes. Corresponds to the 'code' field of the Code
+ * @param code the bytecode of the method corresponding to these Code attributes, or {@literal
+ * null} if they are not Code attributes. Corresponds to the 'code' field of the Code
* attribute.
* @param codeLength the length of the bytecode of the method corresponding to these code
- * attributes, or 0 if they are not code attributes. Corresponds to the 'code_length' field of
+ * attributes, or 0 if they are not Code attributes. Corresponds to the 'code_length' field of
* the Code attribute.
- * @param maxStack the maximum stack size of the method corresponding to these code attributes, or
- * -1 if they are not code attributes.
+ * @param maxStack the maximum stack size of the method corresponding to these Code attributes, or
+ * -1 if they are not Code attributes.
* @param maxLocals the maximum number of local variables of the method corresponding to these
- * code attributes, or -1 if they are not code attribute.
+ * Code attributes, or -1 if they are not Code attribute.
* @return the size of all the attributes in this attribute list. This size includes the size of
* the attribute headers.
*/
@@ -285,16 +285,16 @@
* attribute.
*
* @param symbolTable where the constants used in the attributes must be stored.
- * @param code the bytecode of the method corresponding to these code attributes, or {@literal
- * null} if they are not code attributes. Corresponds to the 'code' field of the Code
+ * @param code the bytecode of the method corresponding to these Code attributes, or {@literal
+ * null} if they are not Code attributes. Corresponds to the 'code' field of the Code
* attribute.
* @param codeLength the length of the bytecode of the method corresponding to these code
- * attributes, or 0 if they are not code attributes. Corresponds to the 'code_length' field of
+ * attributes, or 0 if they are not Code attributes. Corresponds to the 'code_length' field of
* the Code attribute.
- * @param maxStack the maximum stack size of the method corresponding to these code attributes, or
- * -1 if they are not code attributes.
+ * @param maxStack the maximum stack size of the method corresponding to these Code attributes, or
+ * -1 if they are not Code attributes.
* @param maxLocals the maximum number of local variables of the method corresponding to these
- * code attributes, or -1 if they are not code attribute.
+ * Code attributes, or -1 if they are not Code attribute.
* @param output where the attributes must be written.
*/
final void putAttributes(
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java
index cd4a6bb..d6e90a7 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java
@@ -194,7 +194,7 @@
this.b = classFileBuffer;
// Check the class' major_version. This field is after the magic and minor_version fields, which
// use 4 and 2 bytes respectively.
- if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V19) {
+ if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V20) {
throw new IllegalArgumentException(
"Unsupported class file major version " + readShort(classFileOffset + 6));
}
@@ -375,7 +375,7 @@
}
/**
- * Returns the internal of name of the super class (see {@link Type#getInternalName()}). For
+ * Returns the internal name of the super class (see {@link Type#getInternalName()}). For
* interfaces, the super class is {@link Object}.
*
* @return the internal name of the super class, or {@literal null} for {@link Object} class.
@@ -859,7 +859,7 @@
currentOffset += 2;
}
- // Read the 'provides_count' and 'provides' fields.
+ // Read the 'provides_count' and 'provides' fields.
int providesCount = readUnsignedShort(currentOffset);
currentOffset += 2;
while (providesCount-- > 0) {
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassTooLargeException.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassTooLargeException.java
index 8b46201..fefcfe7 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassTooLargeException.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassTooLargeException.java
@@ -42,7 +42,8 @@
/**
* Constructs a new {@link ClassTooLargeException}.
*
- * @param className the internal name of the class.
+ * @param className the internal name of the class (see {@link
+ * jersey.repackaged.org.objectweb.asm.Type#getInternalName()}).
* @param constantPoolCount the number of constant pool items of the class.
*/
public ClassTooLargeException(final String className, final int constantPoolCount) {
@@ -52,7 +53,7 @@
}
/**
- * Returns the internal name of the class.
+ * Returns the internal name of the class (see {@link jersey.repackaged.org.objectweb.asm.Type#getInternalName()}).
*
* @return the internal name of the class.
*/
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassVisitor.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassVisitor.java
index 8ebf594f..44c6535 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassVisitor.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassVisitor.java
@@ -67,7 +67,7 @@
* null.
*/
protected ClassVisitor(final int api, final ClassVisitor classVisitor) {
- if (api != Opcodes.ASM9
+ if (api != Opcodes.ASM9
&& api != Opcodes.ASM8
&& api != Opcodes.ASM7
&& api != Opcodes.ASM6
@@ -84,6 +84,15 @@
}
/**
+ * The class visitor to which this visitor must delegate method calls. May be {@literal null}.
+ *
+ * @return the class visitor to which this visitor must delegate method calls, or {@literal null}.
+ */
+ public ClassVisitor getDelegate() {
+ return cv;
+ }
+
+ /**
* Visits the header of the class.
*
* @param version the class version. The minor version is stored in the 16 most significant bits,
@@ -157,7 +166,8 @@
* implicitly its own nest, so it's invalid to call this method with the visited class name as
* argument.
*
- * @param nestHost the internal name of the host class of the nest.
+ * @param nestHost the internal name of the host class of the nest (see {@link
+ * Type#getInternalName()}).
*/
public void visitNestHost(final String nestHost) {
if (api < Opcodes.ASM7) {
@@ -169,14 +179,19 @@
}
/**
- * Visits the enclosing class of the class. This method must be called only if the class has an
- * enclosing class.
+ * Visits the enclosing class of the class. This method must be called only if this class is a
+ * local or anonymous class. See the JVMS 4.7.7 section for more details.
*
- * @param owner internal name of the enclosing class of the class.
+ * @param owner internal name of the enclosing class of the class (see {@link
+ * Type#getInternalName()}).
* @param name the name of the method that contains the class, or {@literal null} if the class is
- * not enclosed in a method of its enclosing class.
+ * not enclosed in a method or constructor of its enclosing class (e.g. if it is enclosed in
+ * an instance initializer, static initializer, instance variable initializer, or class
+ * variable initializer).
* @param descriptor the descriptor of the method that contains the class, or {@literal null} if
- * the class is not enclosed in a method of its enclosing class.
+ * the class is not enclosed in a method or constructor of its enclosing class (e.g. if it is
+ * enclosed in an instance initializer, static initializer, instance variable initializer, or
+ * class variable initializer).
*/
public void visitOuterClass(final String owner, final String name, final String descriptor) {
if (cv != null) {
@@ -243,7 +258,7 @@
* the visited class is the host of a nest. A nest host is implicitly a member of its own nest, so
* it's invalid to call this method with the visited class name as argument.
*
- * @param nestMember the internal name of a nest member.
+ * @param nestMember the internal name of a nest member (see {@link Type#getInternalName()}).
*/
public void visitNestMember(final String nestMember) {
if (api < Opcodes.ASM7) {
@@ -258,7 +273,8 @@
* Visits a permitted subclasses. A permitted subclass is one of the allowed subclasses of the
* current class.
*
- * @param permittedSubclass the internal name of a permitted subclass.
+ * @param permittedSubclass the internal name of a permitted subclass (see {@link
+ * Type#getInternalName()}).
*/
public void visitPermittedSubclass(final String permittedSubclass) {
if (api < Opcodes.ASM9) {
@@ -271,15 +287,18 @@
/**
* Visits information about an inner class. This inner class is not necessarily a member of the
- * class being visited.
+ * class being visited. More precisely, every class or interface C which is referenced by this
+ * class and which is not a package member must be visited with this method. This class must
+ * reference its nested class or interface members, and its enclosing class, if any. See the JVMS
+ * 4.7.6 section for more details.
*
- * @param name the internal name of an inner class (see {@link Type#getInternalName()}).
- * @param outerName the internal name of the class to which the inner class belongs (see {@link
- * Type#getInternalName()}). May be {@literal null} for not member classes.
- * @param innerName the (simple) name of the inner class inside its enclosing class. May be
- * {@literal null} for anonymous inner classes.
- * @param access the access flags of the inner class as originally declared in the enclosing
- * class.
+ * @param name the internal name of C (see {@link Type#getInternalName()}).
+ * @param outerName the internal name of the class or interface C is a member of (see {@link
+ * Type#getInternalName()}). Must be {@literal null} if C is not the member of a class or
+ * interface (e.g. for local or anonymous classes).
+ * @param innerName the (simple) name of C. Must be {@literal null} for anonymous inner classes.
+ * @param access the access flags of C originally declared in the source code from which this
+ * class was compiled.
*/
public void visitInnerClass(
final String name, final String outerName, final String innerName, final int access) {
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassWriter.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassWriter.java
index de2c441..7bb6ab0 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassWriter.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassWriter.java
@@ -842,7 +842,7 @@
* constant pool already contains a similar item. <i>This method is intended for {@link Attribute}
* sub classes, and is normally not needed by class generators or adapters.</i>
*
- * @param value the internal name of the class.
+ * @param value the internal name of the class (see {@link Type#getInternalName()}).
* @return the index of a new or already existing class reference item.
*/
public int newClass(final String value) {
@@ -894,7 +894,8 @@
* Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, {@link
* Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL},
* {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}.
- * @param owner the internal name of the field or method owner class.
+ * @param owner the internal name of the field or method owner class (see {@link
+ * Type#getInternalName()}).
* @param name the name of the field or method.
* @param descriptor the descriptor of the field or method.
* @return the index of a new or already existing method type reference item.
@@ -916,7 +917,8 @@
* Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, {@link
* Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL},
* {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}.
- * @param owner the internal name of the field or method owner class.
+ * @param owner the internal name of the field or method owner class (see {@link
+ * Type#getInternalName()}).
* @param name the name of the field or method.
* @param descriptor the descriptor of the field or method.
* @param isInterface true if the owner is an interface.
@@ -978,7 +980,7 @@
* constant pool already contains a similar item. <i>This method is intended for {@link Attribute}
* sub classes, and is normally not needed by class generators or adapters.</i>
*
- * @param owner the internal name of the field's owner class.
+ * @param owner the internal name of the field's owner class (see {@link Type#getInternalName()}).
* @param name the field's name.
* @param descriptor the field's descriptor.
* @return the index of a new or already existing field reference item.
@@ -992,7 +994,8 @@
* constant pool already contains a similar item. <i>This method is intended for {@link Attribute}
* sub classes, and is normally not needed by class generators or adapters.</i>
*
- * @param owner the internal name of the method's owner class.
+ * @param owner the internal name of the method's owner class (see {@link
+ * Type#getInternalName()}).
* @param name the method's name.
* @param descriptor the method's descriptor.
* @param isInterface {@literal true} if {@code owner} is an interface.
@@ -1028,9 +1031,10 @@
* currently being generated by this ClassWriter, which can of course not be loaded since it is
* under construction.
*
- * @param type1 the internal name of a class.
- * @param type2 the internal name of another class.
- * @return the internal name of the common super class of the two given classes.
+ * @param type1 the internal name of a class (see {@link Type#getInternalName()}).
+ * @param type2 the internal name of another class (see {@link Type#getInternalName()}).
+ * @return the internal name of the common super class of the two given classes (see {@link
+ * Type#getInternalName()}).
*/
protected String getCommonSuperClass(final String type1, final String type2) {
ClassLoader classLoader = getClassLoader();
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Constants.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Constants.java
index 629d52f..9e7b98c 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Constants.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Constants.java
@@ -26,6 +26,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.
package jersey.repackaged.org.objectweb.asm;
+
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/FieldVisitor.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/FieldVisitor.java
index 64865d6..a75ad5f 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/FieldVisitor.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/FieldVisitor.java
@@ -81,6 +81,15 @@
}
/**
+ * The field visitor to which this visitor must delegate method calls. May be {@literal null}.
+ *
+ * @return the field visitor to which this visitor must delegate method calls, or {@literal null}.
+ */
+ public FieldVisitor getDelegate() {
+ return fv;
+ }
+
+ /**
* Visits an annotation of the field.
*
* @param descriptor the class descriptor of the annotation class.
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Handle.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Handle.java
index 69188e0..60aeb0f 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Handle.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Handle.java
@@ -65,7 +65,7 @@
* {@link Opcodes#H_INVOKESPECIAL}, {@link Opcodes#H_NEWINVOKESPECIAL} or {@link
* Opcodes#H_INVOKEINTERFACE}.
* @param owner the internal name of the class that owns the field or method designated by this
- * handle.
+ * handle (see {@link Type#getInternalName()}).
* @param name the name of the field or method designated by this handle.
* @param descriptor the descriptor of the field or method designated by this handle.
* @deprecated this constructor has been superseded by {@link #Handle(int, String, String, String,
@@ -85,7 +85,7 @@
* {@link Opcodes#H_INVOKESPECIAL}, {@link Opcodes#H_NEWINVOKESPECIAL} or {@link
* Opcodes#H_INVOKEINTERFACE}.
* @param owner the internal name of the class that owns the field or method designated by this
- * handle.
+ * handle (see {@link Type#getInternalName()}).
* @param name the name of the field or method designated by this handle.
* @param descriptor the descriptor of the field or method designated by this handle.
* @param isInterface whether the owner is an interface or not.
@@ -118,7 +118,8 @@
/**
* Returns the internal name of the class that owns the field or method designated by this handle.
*
- * @return the internal name of the class that owns the field or method designated by this handle.
+ * @return the internal name of the class that owns the field or method designated by this handle
+ * (see {@link Type#getInternalName()}).
*/
public String getOwner() {
return owner;
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodTooLargeException.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodTooLargeException.java
index 5ce29f4..303579b 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodTooLargeException.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodTooLargeException.java
@@ -44,7 +44,7 @@
/**
* Constructs a new {@link MethodTooLargeException}.
*
- * @param className the internal name of the owner class.
+ * @param className the internal name of the owner class (see {@link Type#getInternalName()}).
* @param methodName the name of the method.
* @param descriptor the descriptor of the method.
* @param codeSize the size of the method's Code attribute, in bytes.
@@ -64,7 +64,7 @@
/**
* Returns the internal name of the owner class.
*
- * @return the internal name of the owner class.
+ * @return the internal name of the owner class (see {@link Type#getInternalName()}).
*/
public String getClassName() {
return className;
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodVisitor.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodVisitor.java
index 805aed5..269b034 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodVisitor.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodVisitor.java
@@ -96,6 +96,16 @@
this.mv = methodVisitor;
}
+ /**
+ * The method visitor to which this visitor must delegate method calls. May be {@literal null}.
+ *
+ * @return the method visitor to which this visitor must delegate method calls, or {@literal
+ * null}.
+ */
+ public MethodVisitor getDelegate() {
+ return mv;
+ }
+
// -----------------------------------------------------------------------------------------------
// Parameters, annotations and non standard attributes
// -----------------------------------------------------------------------------------------------
@@ -122,7 +132,7 @@
* @return a visitor to the visit the actual default value of this annotation interface method, or
* {@literal null} if this visitor is not interested in visiting this default value. The
* 'name' parameters passed to the methods of this annotation visitor are ignored. Moreover,
- * exacly one visit method must be called on this annotation visitor, followed by visitEnd.
+ * exactly one visit method must be called on this annotation visitor, followed by visitEnd.
*/
public AnnotationVisitor visitAnnotationDefault() {
if (mv != null) {
@@ -275,15 +285,17 @@
* @param type the type of this stack map frame. Must be {@link Opcodes#F_NEW} for expanded
* frames, or {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND}, {@link Opcodes#F_CHOP}, {@link
* Opcodes#F_SAME} or {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for compressed frames.
- * @param numLocal the number of local variables in the visited frame.
+ * @param numLocal the number of local variables in the visited frame. Long and double values
+ * count for one variable.
* @param local the local variable types in this frame. This array must not be modified. Primitive
* types are represented by {@link Opcodes#TOP}, {@link Opcodes#INTEGER}, {@link
* Opcodes#FLOAT}, {@link Opcodes#LONG}, {@link Opcodes#DOUBLE}, {@link Opcodes#NULL} or
* {@link Opcodes#UNINITIALIZED_THIS} (long and double are represented by a single element).
- * Reference types are represented by String objects (representing internal names), and
- * uninitialized types by Label objects (this label designates the NEW instruction that
- * created this uninitialized value).
- * @param numStack the number of operand stack elements in the visited frame.
+ * Reference types are represented by String objects (representing internal names, see {@link
+ * Type#getInternalName()}), and uninitialized types by Label objects (this label designates
+ * the NEW instruction that created this uninitialized value).
+ * @param numStack the number of operand stack elements in the visited frame. Long and double
+ * values count for one stack element.
* @param stack the operand stack types in this frame. This array must not be modified. Its
* content has the same format as the "local" array.
* @throws IllegalStateException if a frame is visited just after another one, without any
@@ -362,7 +374,7 @@
/**
* Visits a type instruction. A type instruction is an instruction that takes the internal name of
- * a class as parameter.
+ * a class as parameter (see {@link Type#getInternalName()}).
*
* @param opcode the opcode of the type instruction to be visited. This opcode is either NEW,
* ANEWARRAY, CHECKCAST or INSTANCEOF.
@@ -645,8 +657,9 @@
* @param start the beginning of the exception handler's scope (inclusive).
* @param end the end of the exception handler's scope (exclusive).
* @param handler the beginning of the exception handler's code.
- * @param type the internal name of the type of exceptions handled by the handler, or {@literal
- * null} to catch any exceptions (for "finally" blocks).
+ * @param type the internal name of the type of exceptions handled by the handler (see {@link
+ * Type#getInternalName()}), or {@literal null} to catch any exceptions (for "finally"
+ * blocks).
* @throws IllegalArgumentException if one of the labels has already been visited by this visitor
* (by the {@link #visitLabel} method).
*/
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleVisitor.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleVisitor.java
index 9667590..aba0283 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleVisitor.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleVisitor.java
@@ -83,9 +83,20 @@
}
/**
+ * The module visitor to which this visitor must delegate method calls. May be {@literal null}.
+ *
+ * @return the module visitor to which this visitor must delegate method calls, or {@literal
+ * null}.
+ */
+ public ModuleVisitor getDelegate() {
+ return mv;
+ }
+
+ /**
* Visit the main class of the current module.
*
- * @param mainClass the internal name of the main class of the current module.
+ * @param mainClass the internal name of the main class of the current module (see {@link
+ * Type#getInternalName()}).
*/
public void visitMainClass(final String mainClass) {
if (mv != null) {
@@ -96,7 +107,7 @@
/**
* Visit a package of the current module.
*
- * @param packaze the internal name of a package.
+ * @param packaze the internal name of a package (see {@link Type#getInternalName()}).
*/
public void visitPackage(final String packaze) {
if (mv != null) {
@@ -121,7 +132,7 @@
/**
* Visit an exported package of the current module.
*
- * @param packaze the internal name of the exported package.
+ * @param packaze the internal name of the exported package (see {@link Type#getInternalName()}).
* @param access the access flag of the exported package, valid values are among {@code
* ACC_SYNTHETIC} and {@code ACC_MANDATED}.
* @param modules the fully qualified names (using dots) of the modules that can access the public
@@ -136,7 +147,7 @@
/**
* Visit an open package of the current module.
*
- * @param packaze the internal name of the opened package.
+ * @param packaze the internal name of the opened package (see {@link Type#getInternalName()}).
* @param access the access flag of the opened package, valid values are among {@code
* ACC_SYNTHETIC} and {@code ACC_MANDATED}.
* @param modules the fully qualified names (using dots) of the modules that can use deep
@@ -152,7 +163,7 @@
* Visit a service used by the current module. The name must be the internal name of an interface
* or a class.
*
- * @param service the internal name of the service.
+ * @param service the internal name of the service (see {@link Type#getInternalName()}).
*/
public void visitUse(final String service) {
if (mv != null) {
@@ -163,9 +174,9 @@
/**
* Visit an implementation of a service.
*
- * @param service the internal name of the service.
- * @param providers the internal names of the implementations of the service (there is at least
- * one provider).
+ * @param service the internal name of the service (see {@link Type#getInternalName()}).
+ * @param providers the internal names (see {@link Type#getInternalName()}) of the implementations
+ * of the service (there is at least one provider).
*/
public void visitProvide(final String service, final String... providers) {
if (mv != null) {
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Opcodes.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Opcodes.java
index 0a591ec..63963b0 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Opcodes.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Opcodes.java
@@ -285,6 +285,7 @@
int V17 = 0 << 16 | 61;
int V18 = 0 << 16 | 62;
int V19 = 0 << 16 | 63;
+ int V20 = 0 << 16 | 64;
/**
* Version flag indicating that the class is using 'preview' features.
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/RecordComponentVisitor.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/RecordComponentVisitor.java
index 65cf92c..e753339 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/RecordComponentVisitor.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/RecordComponentVisitor.java
@@ -45,7 +45,7 @@
/**
* The record visitor to which this visitor must delegate method calls. May be {@literal null}.
*/
- /*package-private*/ RecordComponentVisitor delegate;
+ protected RecordComponentVisitor delegate;
/**
* Constructs a new {@link RecordComponentVisitor}.
@@ -85,7 +85,8 @@
/**
* The record visitor to which this visitor must delegate method calls. May be {@literal null}.
*
- * @return the record visitor to which this visitor must delegate method calls or {@literal null}.
+ * @return the record visitor to which this visitor must delegate method calls, or {@literal
+ * null}.
*/
public RecordComponentVisitor getDelegate() {
return delegate;
diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Type.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Type.java
index ab8687e..6808aba 100644
--- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Type.java
+++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Type.java
@@ -245,7 +245,7 @@
/**
* Returns the {@link Type} corresponding to the given internal name.
*
- * @param internalName an internal name.
+ * @param internalName an internal name (see {@link Type#getInternalName()}).
* @return the {@link Type} corresponding to the given internal name.
*/
public static Type getObjectType(final String internalName) {
diff --git a/core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java b/core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java
index 007cd0a..6c5740e 100644
--- a/core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java
+++ b/core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java
@@ -231,43 +231,50 @@
requestScopeInstance, externalRequestScope.open(injectionManager));
context.initAsyncContext(asyncResponderHolder);
- requestScope.runInScope(requestScopeInstance, new Runnable() {
- @Override
- public void run() {
- try {
- // set base URI into response builder thread-local variable
- // for later resolving of relative location URIs
- if (!disableLocationHeaderRelativeUriResolution) {
- final URI uriToUse =
- rfc7231LocationHeaderRelativeUriResolution ? request.getRequestUri() : request.getBaseUri();
- OutboundJaxrsResponse.Builder.setBaseUri(uriToUse);
+ try {
+ requestScope.runInScope(requestScopeInstance, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ // set base URI into response builder thread-local variable
+ // for later resolving of relative location URIs
+ if (!disableLocationHeaderRelativeUriResolution) {
+ final URI uriToUse =
+ rfc7231LocationHeaderRelativeUriResolution ? request.getRequestUri() : request.getBaseUri();
+ OutboundJaxrsResponse.Builder.setBaseUri(uriToUse);
+ }
+
+ final Ref<Endpoint> endpointRef = Refs.emptyRef();
+ final RequestProcessingContext data = Stages.process(context, requestProcessingRoot, endpointRef);
+
+ final Endpoint endpoint = endpointRef.get();
+ if (endpoint == null) {
+ // not found
+ throw new NotFoundException();
+ }
+
+ final ContainerResponse response = endpoint.apply(data);
+
+ if (!asyncResponderHolder.isAsync()) {
+ responder.process(response);
+ } else {
+ externalRequestScope.suspend(asyncResponderHolder.externalContext, injectionManager);
+ }
+ } catch (final Throwable throwable) {
+ responder.process(throwable);
+ } finally {
+ asyncResponderHolder.release();
+ // clear base URI from the thread
+ OutboundJaxrsResponse.Builder.clearBaseUri();
}
-
- final Ref<Endpoint> endpointRef = Refs.emptyRef();
- final RequestProcessingContext data = Stages.process(context, requestProcessingRoot, endpointRef);
-
- final Endpoint endpoint = endpointRef.get();
- if (endpoint == null) {
- // not found
- throw new NotFoundException();
- }
-
- final ContainerResponse response = endpoint.apply(data);
-
- if (!asyncResponderHolder.isAsync()) {
- responder.process(response);
- } else {
- externalRequestScope.suspend(asyncResponderHolder.externalContext, injectionManager);
- }
- } catch (final Throwable throwable) {
- responder.process(throwable);
- } finally {
- asyncResponderHolder.release();
- // clear base URI from the thread
- OutboundJaxrsResponse.Builder.clearBaseUri();
}
+ });
+ } catch (RuntimeException illegalStateException) {
+ if (!IllegalStateException.class.isInstance(illegalStateException.getCause()) || !injectionManager.isShutdown()) {
+ // consume the IllegalStateException: InjectionManager has been closed.
+ throw illegalStateException;
}
- });
+ }
}
/**
diff --git a/core-server/src/main/java/org/glassfish/jersey/server/internal/scanning/AnnotationAcceptingListener.java b/core-server/src/main/java/org/glassfish/jersey/server/internal/scanning/AnnotationAcceptingListener.java
index 60fdf20..c8c9684 100644
--- a/core-server/src/main/java/org/glassfish/jersey/server/internal/scanning/AnnotationAcceptingListener.java
+++ b/core-server/src/main/java/org/glassfish/jersey/server/internal/scanning/AnnotationAcceptingListener.java
@@ -276,6 +276,12 @@
return null;
}
+ @Override
+ public ClassVisitor getDelegate() {
+ //do nothing
+ return null;
+ }
+
private Class getClassForName(final String className) {
try {
final OsgiRegistry osgiRegistry = ReflectionHelper.getOsgiRegistryInstance();
@@ -303,7 +309,7 @@
private static class ClassReaderWrapper {
private static final Logger LOGGER = Logger.getLogger(ClassReader.class.getName());
- private static final int WARN_VERSION = Opcodes.V19;
+ private static final int WARN_VERSION = Opcodes.V20;
private static final int INPUT_STREAM_DATA_CHUNK_SIZE = 4096;
private final byte[] b;
diff --git a/core-server/src/main/resources/META-INF/NOTICE.markdown b/core-server/src/main/resources/META-INF/NOTICE.markdown
index 9399ca7..f06adeb 100644
--- a/core-server/src/main/resources/META-INF/NOTICE.markdown
+++ b/core-server/src/main/resources/META-INF/NOTICE.markdown
@@ -36,7 +36,7 @@
* Copyright (c) 2015-2018 Oracle and/or its affiliates. All rights reserved.
* Copyright 2010-2013 Coda Hale and Yammer, Inc.
-org.objectweb.asm Version 9.3
+org.objectweb.asm Version 9.4
* License: Modified BSD (https://asm.ow2.io/license.html)
* Copyright: (c) 2000-2011 INRIA, France Telecom. All rights reserved.
diff --git a/examples/json-jackson1/pom.xml b/examples/json-jackson1/pom.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/json-jackson1/pom.xml
diff --git a/ext/cdi/jersey-cdi-rs-inject/pom.xml b/ext/cdi/jersey-cdi-rs-inject/pom.xml
index e766bd0..35f59e1 100644
--- a/ext/cdi/jersey-cdi-rs-inject/pom.xml
+++ b/ext/cdi/jersey-cdi-rs-inject/pom.xml
@@ -45,6 +45,13 @@
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>jakarta.servlet</groupId>
+ <artifactId>jakarta.servlet-api</artifactId>
+ <version>${servlet5.version}</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
</dependencies>
<build>
@@ -66,6 +73,7 @@
<instructions>
<Import-Package>
${cdi.osgi.version},
+ jakarta.servlet.*;version="[5.0, 7.0)";resolution:=optional,
*
</Import-Package>
</instructions>
diff --git a/ext/cdi/jersey-cdi-rs-inject/src/main/java/org/glassfish/jersey/ext/cdi1x/inject/internal/InjectExtension.java b/ext/cdi/jersey-cdi-rs-inject/src/main/java/org/glassfish/jersey/ext/cdi1x/inject/internal/InjectExtension.java
index ad76ddb..22fef89 100644
--- a/ext/cdi/jersey-cdi-rs-inject/src/main/java/org/glassfish/jersey/ext/cdi1x/inject/internal/InjectExtension.java
+++ b/ext/cdi/jersey-cdi-rs-inject/src/main/java/org/glassfish/jersey/ext/cdi1x/inject/internal/InjectExtension.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,12 +22,23 @@
import org.glassfish.jersey.internal.util.collection.Value;
import org.glassfish.jersey.internal.util.collection.Values;
+import jakarta.enterprise.context.RequestScoped;
+import jakarta.enterprise.context.spi.CreationalContext;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.Alternative;
+import jakarta.enterprise.inject.Any;
+import jakarta.enterprise.inject.spi.AfterBeanDiscovery;
+import jakarta.enterprise.inject.spi.AnnotatedType;
+import jakarta.enterprise.inject.spi.Bean;
import jakarta.enterprise.inject.spi.BeanManager;
import jakarta.enterprise.inject.spi.BeforeBeanDiscovery;
import jakarta.enterprise.inject.spi.Extension;
+import jakarta.enterprise.inject.spi.InjectionPoint;
+import jakarta.enterprise.inject.spi.InjectionTarget;
+import jakarta.enterprise.inject.spi.InjectionTargetFactory;
+import jakarta.enterprise.inject.spi.PassivationCapable;
import jakarta.enterprise.inject.spi.ProcessAnnotatedType;
+import jakarta.inject.Singleton;
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.container.ResourceContext;
import jakarta.ws.rs.container.ResourceInfo;
@@ -40,9 +51,13 @@
import jakarta.ws.rs.ext.ParamConverterProvider;
import jakarta.ws.rs.ext.Providers;
import jakarta.ws.rs.sse.Sse;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
import java.security.AccessController;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import java.util.UUID;
/**
* <p>
@@ -57,7 +72,12 @@
*/
@SuppressWarnings("unused")
class InjectExtension implements Extension {
- private void processAnnotatedType(@Observes ProcessAnnotatedType<?> processAnnotatedType, BeanManager beanManager) {
+ private static final Class<?> WEB_CONFIG_CLASS =
+ AccessController.doPrivileged(ReflectionHelper.classForNamePA("org.glassfish.jersey.servlet.WebConfig"));
+ private AnnotatedType<ServletReferenceProducer> interceptorAnnotatedType;
+
+ private void processAnnotatedType(@Observes ProcessAnnotatedType<?> processAnnotatedType,
+ BeanManager beanManager) {
final Class<?> baseClass = (Class<?>) processAnnotatedType.getAnnotatedType().getBaseType();
if (Application.class.isAssignableFrom(baseClass) && Configuration.class.isAssignableFrom(baseClass)) {
if (!baseClass.isAnnotationPresent(Alternative.class)) {
@@ -67,8 +87,103 @@
}
private void beforeDiscoveryObserver(@Observes final BeforeBeanDiscovery bbf, final BeanManager beanManager) {
- final CdiComponentProvider cdiComponentProvider = beanManager.getExtension(CdiComponentProvider.class);
- cdiComponentProvider.addHK2DepenendencyCheck(InjectExtension::isHK2Dependency);
+ if (WEB_CONFIG_CLASS != null) {
+ interceptorAnnotatedType = beanManager.createAnnotatedType(ServletReferenceProducer.class);
+ bbf.addAnnotatedType(interceptorAnnotatedType, ServletReferenceProducer.class.getName());
+ }
+ CdiComponentProvider.addHK2DepenendencyCheck(InjectExtension::isHK2Dependency);
+ }
+
+ private void afterDiscoveryObserver(@Observes final AfterBeanDiscovery abd, final BeanManager beanManager) {
+ if (WEB_CONFIG_CLASS != null) {
+ abd.addBean(new ServletReferenceProducerBean(beanManager));
+ }
+ }
+
+ @Singleton
+ private final class ServletReferenceProducerBean implements Bean<ServletReferenceProducer>, PassivationCapable {
+ private final Set<Annotation> qualifiers = new HashSet<>();
+ private final Set<Type> types = new HashSet<>(2);
+ private final InjectionTarget<ServletReferenceProducer> interceptorTarget;
+ private final String id = UUID.randomUUID().toString();
+
+ private ServletReferenceProducerBean(BeanManager beanManager) {
+ qualifiers.add(new CdiJerseyContextAnnotation());
+ qualifiers.add(new CdiAnyAnnotation());
+
+ types.add(ServletReferenceProducer.class);
+ types.add(Object.class);
+
+ final AnnotatedType<ServletReferenceProducer> interceptorType = interceptorAnnotatedType;
+ final InjectionTargetFactory<ServletReferenceProducer> injectionTargetFactory =
+ beanManager.getInjectionTargetFactory(interceptorType);
+
+ interceptorTarget = injectionTargetFactory.createInjectionTarget(null);
+ }
+ @Override
+ public Set<Type> getTypes() {
+ return types;
+ }
+
+ @Override
+ public Set<Annotation> getQualifiers() {
+ return qualifiers;
+ }
+
+ @Override
+ public Class<? extends Annotation> getScope() {
+ return RequestScoped.class;
+ }
+
+ @Override
+ public String getName() {
+ return ServletReferenceProducer.class.getName();
+ }
+
+ @Override
+ public Set<Class<? extends Annotation>> getStereotypes() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public boolean isAlternative() {
+ return false;
+ }
+
+ @Override
+ public ServletReferenceProducer create(CreationalContext<ServletReferenceProducer> creationalContext) {
+ final ServletReferenceProducer result = interceptorTarget.produce(creationalContext);
+ interceptorTarget.inject(result, creationalContext);
+ interceptorTarget.postConstruct(result);
+ return result;
+ }
+
+ @Override
+ public void destroy(ServletReferenceProducer servletProducer,
+ CreationalContext<ServletReferenceProducer> creationalContext) {
+ interceptorTarget.preDestroy(servletProducer);
+ interceptorTarget.dispose(servletProducer);
+ creationalContext.release();
+ }
+
+ @Override
+ public Class<?> getBeanClass() {
+ return ServletReferenceProducer.class;
+ }
+
+ @Override
+ public Set<InjectionPoint> getInjectionPoints() {
+ return interceptorTarget.getInjectionPoints();
+ }
+
+ public boolean isNullable() {
+ return false;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
}
private static final boolean isHK2Dependency(Class<?> clazz) {
@@ -95,20 +210,17 @@
injectables.add(Sse.class);
injectables.add(UriInfo.class);
- //Servlet if available
- addOptionally("jakarta.servlet.http.HttpServletRequest", injectables);
- addOptionally("jakarta.servlet.http.HttpServletResponse", injectables);
- addOptionally("jakarta.servlet.ServletConfig", injectables);
- addOptionally("jakarta.servlet.ServletContext", injectables);
- addOptionally("jakarta.servlet.FilterConfig", injectables);
-
return injectables;
}
- private static void addOptionally(String className, Set<Class<?>> set) {
- final Class<?> optionalClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA(className));
- if (optionalClass != null) {
- set.add(optionalClass);
- }
+ private static class CdiJerseyContextAnnotation
+ extends jakarta.enterprise.util.AnnotationLiteral<JerseyContext> implements JerseyContext {
+ private static final long serialVersionUID = 1L;
}
+
+ private static class CdiAnyAnnotation
+ extends jakarta.enterprise.util.AnnotationLiteral<Any> implements Any {
+ private static final long serialVersionUID = 1L;
+ }
+
}
diff --git a/ext/cdi/jersey-cdi-rs-inject/src/main/java/org/glassfish/jersey/ext/cdi1x/inject/internal/JerseyContext.java b/ext/cdi/jersey-cdi-rs-inject/src/main/java/org/glassfish/jersey/ext/cdi1x/inject/internal/JerseyContext.java
new file mode 100644
index 0000000..d7ab053
--- /dev/null
+++ b/ext/cdi/jersey-cdi-rs-inject/src/main/java/org/glassfish/jersey/ext/cdi1x/inject/internal/JerseyContext.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.ext.cdi1x.inject.internal;
+
+import jakarta.inject.Qualifier;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p>
+ * Qualifier used for injecting the CDI beans using {@code @Inject}. Used only for beans that originate in Specification other
+ * than Jakarta RESTful Web Services (such as Servlet). Such beans must not be produced with {@code @Default} qualifier so that
+ * there is no ambiguity for the CDI injection.
+ * </p>
+ * <p>
+ * Jakarta REST Spec. Section 11 demands {@code HttpServletRequest}, {@code HttpServletResponse}, {@code ServletContext},
+ * {@code ServletConfig}, and {@code FilterConfig} to be available by injections using {@code @Context}. For CDI, these
+ * servlet classes are available with {@link JerseyContext} qualifier.
+ * </p>
+ * <p>
+ * Note that {@code @Context} injection is not aware of the qualifier and using {@code @Context} in conjuction with
+ * {@code @JerseyContext} will not work.
+ * </p>
+ * <p>
+ * Can be used as e.g.
+ *
+ * <pre>
+ * @Inject
+ * @JerseyContext //internal
+ * HttpServletRequest httpServletRequest;
+ * </pre>
+ * or as iterable of all {@code HttpServletRequest} beans
+ * <pre>
+ * @Inject
+ * @Any
+ * Instance<HttpServletRequest> httpServletRequests;
+ * </pre>
+ * </p>
+ * @since 2.38
+ */
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
+public @interface JerseyContext {
+}
diff --git a/ext/cdi/jersey-cdi-rs-inject/src/main/java/org/glassfish/jersey/ext/cdi1x/inject/internal/ServletReferenceProducer.java b/ext/cdi/jersey-cdi-rs-inject/src/main/java/org/glassfish/jersey/ext/cdi1x/inject/internal/ServletReferenceProducer.java
new file mode 100644
index 0000000..64a1069
--- /dev/null
+++ b/ext/cdi/jersey-cdi-rs-inject/src/main/java/org/glassfish/jersey/ext/cdi1x/inject/internal/ServletReferenceProducer.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.ext.cdi1x.inject.internal;
+
+import org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider;
+import org.glassfish.jersey.internal.inject.InjectionManager;
+
+import jakarta.enterprise.context.RequestScoped;
+import jakarta.enterprise.inject.Produces;
+import jakarta.enterprise.inject.spi.BeanManager;
+import jakarta.inject.Inject;
+import jakarta.servlet.FilterConfig;
+import jakarta.servlet.ServletConfig;
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+
+/**
+ * A CDI producer producing servlet beans in a {@code RequestScope}.
+ */
+class ServletReferenceProducer {
+ @Inject
+ InjectionManager injectionManager;
+
+ @Inject
+ BeanManager beanManager;
+
+ @Produces
+ @JerseyContext
+ @RequestScoped
+ public HttpServletRequest produceHttpServletRequest() {
+ return injectionManager().getInstance(HttpServletRequest.class);
+ }
+
+ @Produces
+ @JerseyContext
+ @RequestScoped
+ public HttpServletResponse produceHttpServletResponse() {
+ return injectionManager().getInstance(HttpServletResponse.class);
+ }
+
+ @Produces
+ @JerseyContext
+ @RequestScoped
+ public ServletContext produceServletContext() {
+ return injectionManager().getInstance(ServletContext.class);
+ }
+
+ @Produces
+ @JerseyContext
+ @RequestScoped
+ public ServletConfig produceServletConfig() {
+ return injectionManager().getInstance(ServletConfig.class);
+ }
+
+ @Produces
+ @JerseyContext
+ @RequestScoped
+ public FilterConfig produceFilterConfig() {
+ return injectionManager().getInstance(FilterConfig.class);
+ }
+
+ private InjectionManager injectionManager() {
+ InjectionManager injectionManager = beanManager.getExtension(CdiComponentProvider.class).getEffectiveInjectionManager();
+ if (injectionManager != null && !injectionManager.isShutdown()) {
+ return injectionManager;
+ }
+ return this.injectionManager;
+ }
+}
diff --git a/ext/cdi/jersey-cdi1x/src/main/java/org/glassfish/jersey/ext/cdi1x/internal/CdiComponentProvider.java b/ext/cdi/jersey-cdi1x/src/main/java/org/glassfish/jersey/ext/cdi1x/internal/CdiComponentProvider.java
index 498f041..e5fd3e8 100644
--- a/ext/cdi/jersey-cdi1x/src/main/java/org/glassfish/jersey/ext/cdi1x/internal/CdiComponentProvider.java
+++ b/ext/cdi/jersey-cdi1x/src/main/java/org/glassfish/jersey/ext/cdi1x/internal/CdiComponentProvider.java
@@ -18,8 +18,6 @@
package org.glassfish.jersey.ext.cdi1x.internal;
import java.lang.annotation.Annotation;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
@@ -49,8 +47,6 @@
import jakarta.annotation.ManagedBean;
-import jakarta.annotation.Priority;
-import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Dependent;
import jakarta.enterprise.context.RequestScoped;
import jakarta.enterprise.context.spi.CreationalContext;
@@ -64,8 +60,6 @@
import jakarta.enterprise.inject.spi.AnnotatedParameter;
import jakarta.enterprise.inject.spi.AnnotatedType;
import jakarta.enterprise.inject.spi.Bean;
-import jakarta.enterprise.inject.spi.BeanManager;
-import jakarta.enterprise.inject.spi.BeforeBeanDiscovery;
import jakarta.enterprise.inject.spi.BeforeShutdown;
import jakarta.enterprise.inject.spi.Extension;
import jakarta.enterprise.inject.spi.InjectionPoint;
@@ -73,7 +67,6 @@
import jakarta.enterprise.inject.spi.ProcessAnnotatedType;
import jakarta.enterprise.inject.spi.ProcessInjectionTarget;
import jakarta.enterprise.util.AnnotationLiteral;
-import jakarta.inject.Qualifier;
import org.glassfish.jersey.ext.cdi1x.internal.spi.InjectionManagerInjectedTarget;
import org.glassfish.jersey.ext.cdi1x.internal.spi.InjectionManagerStore;
@@ -90,19 +83,10 @@
import org.glassfish.jersey.internal.inject.SupplierInstanceBinding;
import org.glassfish.jersey.internal.util.collection.Cache;
import org.glassfish.jersey.model.ContractProvider;
-import org.glassfish.jersey.server.model.Parameter;
-import org.glassfish.jersey.server.ContainerRequest;
-import org.glassfish.jersey.server.spi.internal.ValueParamProvider;
import org.glassfish.jersey.spi.ComponentProvider;
import org.glassfish.hk2.api.ClassAnalyzer;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
/**
* Jersey CDI integration implementation.
* Implements {@link ComponentProvider Jersey component provider} to serve CDI beans
@@ -132,7 +116,7 @@
private final Set<Type> jaxrsInjectableTypes = new HashSet<>();
private final Set<Type> hk2ProvidedTypes = Collections.synchronizedSet(new HashSet<Type>());
private final Set<Type> jerseyVetoedTypes = Collections.synchronizedSet(new HashSet<Type>());
- private final Set<DependencyPredicate> jerseyOrDependencyTypes = Collections.synchronizedSet(new LinkedHashSet<>());
+ private static final Set<DependencyPredicate> jerseyOrDependencyTypes = Collections.synchronizedSet(new LinkedHashSet<>());
private final ThreadLocal<InjectionManager> threadInjectionManagers = new ThreadLocal<>();
/**
@@ -187,92 +171,6 @@
}
}
- /**
- * CDI producer for CDI bean constructor String parameters, that should be injected by JAX-RS.
- */
- @ApplicationScoped
- public static class JaxRsParamProducer {
-
- @Qualifier
- @Retention(RUNTIME)
- @Target({METHOD, FIELD, PARAMETER, TYPE})
- public static @interface JaxRsParamQualifier {
- }
-
- private static final JaxRsParamQualifier JaxRsParamQUALIFIER = new JaxRsParamQualifier() {
-
- @Override
- public Class<? extends Annotation> annotationType() {
- return JaxRsParamQualifier.class;
- }
- };
-
- static final Set<Class<? extends Annotation>> JAX_RS_STRING_PARAM_ANNOTATIONS =
- new HashSet<Class<? extends Annotation>>() {{
- add(jakarta.ws.rs.PathParam.class);
- add(jakarta.ws.rs.QueryParam.class);
- add(jakarta.ws.rs.CookieParam.class);
- add(jakarta.ws.rs.HeaderParam.class);
- add(jakarta.ws.rs.MatrixParam.class);
- add(jakarta.ws.rs.FormParam.class);
- }};
-
- /**
- * Internal cache to store CDI {@link InjectionPoint} to Jersey {@link Parameter} mapping.
- */
- final Cache<InjectionPoint, Parameter> parameterCache = new Cache<>(injectionPoint -> {
- final Annotated annotated = injectionPoint.getAnnotated();
- final Class<?> clazz = injectionPoint.getMember().getDeclaringClass();
-
- if (annotated instanceof AnnotatedParameter) {
-
- final AnnotatedParameter annotatedParameter = (AnnotatedParameter) annotated;
- final AnnotatedCallable callable = annotatedParameter.getDeclaringCallable();
-
- if (callable instanceof AnnotatedConstructor) {
-
- final AnnotatedConstructor ac = (AnnotatedConstructor) callable;
- final int position = annotatedParameter.getPosition();
- final List<Parameter> parameters = Parameter.create(clazz, clazz, ac.getJavaMember(), false);
-
- return parameters.get(position);
- }
- }
-
- return null;
- });
-
- /**
- * Provide a value for given injection point. If the injection point does not refer
- * to a CDI bean constructor parameter, or the value could not be found, the method will return null.
- *
- * @param injectionPoint actual injection point.
- * @param beanManager current application bean manager.
- * @return concrete JAX-RS parameter value for given injection point.
- */
- @jakarta.enterprise.inject.Produces
- @JaxRsParamQualifier
- public String getParameterValue(final InjectionPoint injectionPoint, final BeanManager beanManager) {
- final Parameter parameter = parameterCache.apply(injectionPoint);
-
- if (parameter != null) {
- InjectionManager injectionManager =
- beanManager.getExtension(CdiComponentProvider.class).getEffectiveInjectionManager();
-
- Set<ValueParamProvider> providers = Providers.getProviders(injectionManager, ValueParamProvider.class);
- ContainerRequest containerRequest = injectionManager.getInstance(ContainerRequest.class);
- for (ValueParamProvider vfp : providers) {
- Function<ContainerRequest, ?> paramValueSupplier = vfp.getValueProvider(parameter);
- if (paramValueSupplier != null) {
- return (String) paramValueSupplier.apply(containerRequest);
- }
- }
- }
-
- return null;
- }
- }
-
@Override
public boolean bind(final Class<?> clazz, final Set<Class<?>> providerContracts) {
return bind(clazz, providerContracts, ContractProvider.NO_PRIORITY);
@@ -654,7 +552,7 @@
*
* @return HK2 injection manager.
*/
- /* package */ InjectionManager getEffectiveInjectionManager() {
+ public InjectionManager getEffectiveInjectionManager() {
return injectionManagerStore.getEffectiveInjectionManager();
}
@@ -771,7 +669,7 @@
@Override
public void inject(final Object t, final CreationalContext cc) {
InjectionManager injectingManager = getEffectiveInjectionManager();
- if (injectingManager == null) {
+ if (injectingManager == null || /* reload */ injectingManager.isShutdown()) {
injectingManager = effectiveInjectionManager;
threadInjectionManagers.set(injectingManager);
}
@@ -837,7 +735,7 @@
@Override
public Object create(final CreationalContext creationalContext) {
InjectionManager injectionManager = getEffectiveInjectionManager();
- if (injectionManager == null) {
+ if (injectionManager == null || /* reload */ injectionManager.isShutdown()) {
injectionManager = threadInjectionManagers.get();
}
@@ -970,11 +868,11 @@
* Add a predicate to test HK2 dependency to create a CDI bridge bean to HK2 for it.
* @param predicate to test whether given class is a HK2 dependency.
*/
- public void addHK2DepenendencyCheck(Predicate<Class<?>> predicate) {
+ public static void addHK2DepenendencyCheck(Predicate<Class<?>> predicate) {
jerseyOrDependencyTypes.add(new DependencyPredicate(predicate));
}
- private final class DependencyPredicate implements Predicate<Class<?>> {
+ private static final class DependencyPredicate implements Predicate<Class<?>> {
private final Predicate<Class<?>> predicate;
public DependencyPredicate(Predicate<Class<?>> predicate) {
@@ -991,7 +889,7 @@
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DependencyPredicate that = (DependencyPredicate) o;
- return predicate.getClass().equals(that.predicate);
+ return predicate.getClass().equals(that.predicate.getClass());
}
@Override
diff --git a/ext/microprofile/mp-rest-client/pom.xml b/ext/microprofile/mp-rest-client/pom.xml
index c85a4b0..bf2013b 100644
--- a/ext/microprofile/mp-rest-client/pom.xml
+++ b/ext/microprofile/mp-rest-client/pom.xml
@@ -114,6 +114,7 @@
<Import-Package>
${cdi.osgi.version},
jakarta.decorator.*;version="[3.0,5)",
+ org.eclipse.microprofile.rest.client.*;version="[3.0,4)",
org.eclipse.microprofile.config.*;version="!",
*
</Import-Package>
diff --git a/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/managed/BinderRegisterExtension.java b/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/managed/BinderRegisterExtension.java
index 260f008..60d48e4 100644
--- a/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/managed/BinderRegisterExtension.java
+++ b/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/managed/BinderRegisterExtension.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -598,6 +598,11 @@
}
@Override
+ public boolean isShutdown() {
+ return false;
+ }
+
+ @Override
public void register(Binding binding) {
BinderRegisterExtension.this.register(runtimeType, binding);
}
diff --git a/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/managed/CdiInjectionManager.java b/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/managed/CdiInjectionManager.java
index 62745e1..e5759ea 100644
--- a/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/managed/CdiInjectionManager.java
+++ b/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/managed/CdiInjectionManager.java
@@ -333,6 +333,11 @@
}
+ @Override
+ public boolean isShutdown() {
+ return false;
+ }
+
protected Binder getBindings() {
return bindings;
}
diff --git a/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/managed/WrappingInjectionManager.java b/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/managed/WrappingInjectionManager.java
index a3bea1a..5d40bfa 100644
--- a/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/managed/WrappingInjectionManager.java
+++ b/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/managed/WrappingInjectionManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -51,6 +51,11 @@
}
@Override
+ public boolean isShutdown() {
+ return injectionManager.isShutdown();
+ }
+
+ @Override
public void register(Binding binding) {
injectionManager.register(binding);
}
diff --git a/inject/cdi2-se/src/main/java/org/glassfish/jersey/inject/cdi/se/CdiSeInjectionManager.java b/inject/cdi2-se/src/main/java/org/glassfish/jersey/inject/cdi/se/CdiSeInjectionManager.java
index d6aef9a..7d201f1 100644
--- a/inject/cdi2-se/src/main/java/org/glassfish/jersey/inject/cdi/se/CdiSeInjectionManager.java
+++ b/inject/cdi2-se/src/main/java/org/glassfish/jersey/inject/cdi/se/CdiSeInjectionManager.java
@@ -290,6 +290,11 @@
}
@Override
+ public boolean isShutdown() {
+ return !container.isRunning();
+ }
+
+ @Override
public void inject(Object injectMe, String classAnalyzer) {
// TODO: Used only in legacy CDI integration.
throw new UnsupportedOperationException();
diff --git a/inject/hk2/src/main/java/org/glassfish/jersey/inject/hk2/AbstractHk2InjectionManager.java b/inject/hk2/src/main/java/org/glassfish/jersey/inject/hk2/AbstractHk2InjectionManager.java
index 5a71084..94d5f8c 100644
--- a/inject/hk2/src/main/java/org/glassfish/jersey/inject/hk2/AbstractHk2InjectionManager.java
+++ b/inject/hk2/src/main/java/org/glassfish/jersey/inject/hk2/AbstractHk2InjectionManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -185,6 +185,11 @@
}
@Override
+ public boolean isShutdown() {
+ return getServiceLocator().isShutdown();
+ }
+
+ @Override
public <U> U create(Class<U> clazz) {
return getServiceLocator().create(clazz);
}
diff --git a/media/json-jackson1/pom.xml b/media/json-jackson1/pom.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/media/json-jackson1/pom.xml
diff --git a/pom.xml b/pom.xml
index bdde4d3..d73ec69 100644
--- a/pom.xml
+++ b/pom.xml
@@ -449,7 +449,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
- <version>3.1.2</version>
+ <version>3.3.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -2131,7 +2131,7 @@
<jersey.version>${project.version}</jersey.version>
<!-- asm is now source integrated - keeping this property to see the version -->
<!-- see core-server/src/main/java/jersey/repackaged/asm/.. -->
- <asm.version>9.3</asm.version>
+ <asm.version>9.4</asm.version>
<bnd.plugin.version>2.3.6</bnd.plugin.version>
<bouncycastle.version>1.68</bouncycastle.version>
diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ApplicationInjectParent.java b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ApplicationInjectParent.java
index f3b9cd5..398b13c 100644
--- a/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ApplicationInjectParent.java
+++ b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ApplicationInjectParent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -37,7 +37,6 @@
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.SecurityContext;
import jakarta.ws.rs.core.UriInfo;
-import jakarta.ws.rs.ext.ParamConverterProvider;
import jakarta.ws.rs.ext.Providers;
import java.lang.reflect.Field;
import java.util.Iterator;
@@ -96,9 +95,6 @@
@Context
protected HttpServletRequest contextHttpServletRequest;
- @Inject
- protected HttpServletRequest injectHttpServletRequest;
-
@Context
protected WebConfig contextWebConfig;
@@ -108,21 +104,12 @@
@Context
protected HttpServletResponse contextHttpServletResponse;
- @Inject
- protected HttpServletResponse injectHttpServletResponse;
-
@Context
protected ServletConfig contextServletConfig;
- @Inject
- protected ServletConfig injectServletConfig;
-
@Context
protected ServletContext contextServletContext;
- @Inject
- protected ServletContext injectServletContext;
-
static class InjectHolder extends ParentInject {
@Override
diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ParentInject.java b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ParentInject.java
index c774e86..05bd1da 100644
--- a/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ParentInject.java
+++ b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ParentInject.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -33,7 +33,6 @@
import jakarta.ws.rs.core.Request;
import jakarta.ws.rs.core.SecurityContext;
import jakarta.ws.rs.core.UriInfo;
-import jakarta.ws.rs.ext.ParamConverterProvider;
import jakarta.ws.rs.ext.Providers;
public class ParentInject implements ParentChecker {
@@ -106,9 +105,6 @@
@Context
protected HttpServletRequest contextHttpServletRequest;
- @Inject
- protected HttpServletRequest injectHttpServletRequest;
-
@Context
protected WebConfig contextWebConfig;
@@ -118,21 +114,12 @@
@Context
protected HttpServletResponse contextHttpServletResponse;
- @Inject
- protected HttpServletResponse injectHttpServletResponse;
-
@Context
protected ServletConfig contextServletConfig;
- @Inject
- protected ServletConfig injectServletConfig;
-
@Context
protected ServletContext contextServletContext;
- @Inject
- protected ServletContext injectServletContext;
-
@Override
public boolean checkInjected(StringBuilder stringBuilder) {
boolean injected = true;
@@ -148,11 +135,7 @@
injected &= InjectionChecker.checkSecurityContext(injectSecurityContext, stringBuilder);
injected &= InjectionChecker.checkUriInfo(injectUriInfo, stringBuilder);
- injected &= InjectionChecker.checkHttpServletRequest(injectHttpServletRequest, stringBuilder);
- injected &= InjectionChecker.checkHttpServletResponse(injectHttpServletResponse, stringBuilder);
injected &= InjectionChecker.checkWebConfig(injectWebConfig, stringBuilder);
- injected &= InjectionChecker.checkServletConfig(injectServletConfig, stringBuilder);
- injected &= InjectionChecker.checkServletContext(injectServletContext, stringBuilder);
return injected;
}
@@ -182,7 +165,7 @@
}
protected boolean checkApplication(Application application, StringBuilder stringBuilder) {
- return InjectionChecker.checkApplication(contextApplication, stringBuilder);
+ return InjectionChecker.checkApplication(application, stringBuilder);
}
protected boolean checkConfiguration(Configuration configuration, StringBuilder stringBuilder) {
diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletApplication.java b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletApplication.java
new file mode 100644
index 0000000..dddd0bd
--- /dev/null
+++ b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletApplication.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.cdi.inject;
+
+import org.glassfish.jersey.server.ResourceConfig;
+
+import jakarta.enterprise.context.ApplicationScoped;
+
+@ApplicationScoped
+public class ServletApplication extends ResourceConfig {
+ ServletApplication() {
+ super(ServletExceptionMapper.class,
+ ServletResponseFilter.class,
+ ServletRequestFilter.class,
+ ServletResource.class);
+ }
+}
diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletExceptionMapper.java b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletExceptionMapper.java
new file mode 100644
index 0000000..192c023
--- /dev/null
+++ b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletExceptionMapper.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.cdi.inject;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.ext.ExceptionMapper;
+
+@ApplicationScoped
+public class ServletExceptionMapper extends ServletInject implements ExceptionMapper<IllegalArgumentException> {
+ @Override
+ public Response toResponse(IllegalArgumentException exception) {
+ return super.check();
+ }
+}
diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletInject.java b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletInject.java
new file mode 100644
index 0000000..366abe8
--- /dev/null
+++ b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletInject.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.cdi.inject;
+
+import jakarta.enterprise.inject.Any;
+import jakarta.inject.Inject;
+import jakarta.servlet.ServletConfig;
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.ws.rs.core.Response;
+
+public class ServletInject {
+ @Inject
+ @Any
+ protected HttpServletRequest injectHttpServletRequest;
+
+ @Inject
+ @Any
+ protected HttpServletResponse injectHttpServletResponse;
+
+ @Inject
+ @Any
+ protected ServletConfig injectServletConfig;
+
+ @Inject
+ @Any
+ protected ServletContext injectServletContext;
+
+ public boolean check(StringBuilder sb) {
+ boolean injected = true;
+ injected &= InjectionChecker.checkHttpServletRequest(injectHttpServletRequest, sb);
+ injected &= InjectionChecker.checkHttpServletResponse(injectHttpServletResponse, sb);
+ injected &= InjectionChecker.checkServletConfig(injectServletConfig, sb);
+ injected &= InjectionChecker.checkServletContext(injectServletContext, sb);
+ return injected;
+ }
+
+ public Response check() {
+ StringBuilder sb = new StringBuilder();
+ if (check(sb)) {
+ return Response.ok().entity("All injected").build();
+ } else {
+ return Response.status(Response.Status.EXPECTATION_FAILED).entity(sb.toString()).build();
+ }
+ }
+}
diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletRequestFilter.java b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletRequestFilter.java
new file mode 100644
index 0000000..e9677e9
--- /dev/null
+++ b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletRequestFilter.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.cdi.inject;
+
+import jakarta.enterprise.context.RequestScoped;
+import jakarta.ws.rs.container.ContainerRequestContext;
+import jakarta.ws.rs.container.ContainerRequestFilter;
+import jakarta.ws.rs.core.Response;
+import java.io.IOException;
+
+@RequestScoped
+public class ServletRequestFilter extends ServletInject implements ContainerRequestFilter {
+ @Override
+ public void filter(ContainerRequestContext requestContext) throws IOException {
+ Response response = super.check();
+ if (response.getStatus() != Response.Status.OK.getStatusCode()) {
+ requestContext.abortWith(response);
+ }
+ }
+}
diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletResource.java b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletResource.java
new file mode 100644
index 0000000..a9ecae9
--- /dev/null
+++ b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletResource.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.cdi.inject;
+
+import jakarta.enterprise.context.RequestScoped;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.core.Response;
+
+@RequestScoped
+@Path("/servlet")
+public class ServletResource extends ServletInject {
+
+ @GET
+ public Response checkApp() {
+ return super.check();
+ }
+
+ @GET
+ @Path("exception")
+ public Response throwE() {
+ throw new IllegalArgumentException();
+ }
+}
diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletResponseFilter.java b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletResponseFilter.java
new file mode 100644
index 0000000..04de69b
--- /dev/null
+++ b/tests/integration/cdi-integration/context-inject-on-server/src/main/java/org/glassfish/jersey/tests/cdi/inject/ServletResponseFilter.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.cdi.inject;
+
+import jakarta.enterprise.context.RequestScoped;
+import jakarta.ws.rs.container.ContainerRequestContext;
+import jakarta.ws.rs.container.ContainerResponseContext;
+import jakarta.ws.rs.container.ContainerResponseFilter;
+import jakarta.ws.rs.core.Response;
+import java.io.IOException;
+
+@RequestScoped
+public class ServletResponseFilter extends ServletInject implements ContainerResponseFilter {
+ @Override
+ public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
+ if (responseContext.getStatus() != Response.Status.OK.getStatusCode()) {
+ Response response = super.check();
+ if (response.getStatus() != Response.Status.OK.getStatusCode()) {
+ responseContext.setStatus(response.getStatus());
+ responseContext.setEntity(response.getEntity());
+ }
+ }
+ }
+}
diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ServletTest.java b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ServletTest.java
new file mode 100644
index 0000000..73e8e72
--- /dev/null
+++ b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ServletTest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.cdi.inject;
+
+import org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory;
+import org.glassfish.jersey.servlet.ServletProperties;
+import org.glassfish.jersey.test.DeploymentContext;
+import org.glassfish.jersey.test.JerseyTest;
+import org.glassfish.jersey.test.ServletDeploymentContext;
+import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory;
+import org.glassfish.jersey.test.spi.TestContainerException;
+import org.glassfish.jersey.test.spi.TestContainerFactory;
+import org.jboss.weld.environment.se.Weld;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+import jakarta.ws.rs.core.Application;
+import jakarta.ws.rs.core.Response;
+
+public class ServletTest extends JerseyTest {
+ private Weld weld;
+
+ @Before
+ public void setup() {
+ Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy());
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
+ weld = new Weld();
+ weld.initialize();
+ super.setUp();
+ }
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
+ weld.shutdown();
+ super.tearDown();
+ }
+ }
+
+ @Override
+ protected Application configure() {
+ return new ServletApplication();
+ }
+
+ @Override
+ protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
+ return new GrizzlyWebTestContainerFactory();
+ }
+
+ @Override
+ protected DeploymentContext configureDeployment() {
+ return ServletDeploymentContext.builder(configure())
+ .initParam(ServletProperties.JAXRS_APPLICATION_CLASS, ServletApplication.class.getName())
+ .build();
+ }
+
+ @Test
+ public void testServlet() {
+ try (Response response = target("servlet").request().header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) {
+ if (response.getStatus() != Response.Status.OK.getStatusCode()) {
+ System.out.println(response.readEntity(String.class));
+ }
+ Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
+ }
+ }
+
+ @Test
+ public void testServletExceptionMapper() {
+ try (Response response = target("servlet/exception").request()
+ .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) {
+ if (response.getStatus() != Response.Status.OK.getStatusCode()) {
+ System.out.println(response.readEntity(String.class));
+ }
+ Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
+ }
+ }
+
+}
diff --git a/tests/integration/cdi-integration/gf-cdi-inject/src/main/java/org/glassfish/jersey/tests/cdi/gf/GFTestApp.java b/tests/integration/cdi-integration/gf-cdi-inject/src/main/java/org/glassfish/jersey/tests/cdi/gf/GFTestApp.java
index 116e923..7590194 100644
--- a/tests/integration/cdi-integration/gf-cdi-inject/src/main/java/org/glassfish/jersey/tests/cdi/gf/GFTestApp.java
+++ b/tests/integration/cdi-integration/gf-cdi-inject/src/main/java/org/glassfish/jersey/tests/cdi/gf/GFTestApp.java
@@ -18,13 +18,40 @@
import org.glassfish.jersey.CommonProperties;
import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.server.spi.Container;
+import org.glassfish.jersey.server.spi.ContainerLifecycleListener;
import jakarta.ws.rs.ApplicationPath;
@ApplicationPath("/test")
public class GFTestApp extends ResourceConfig {
+ public static final String RELOADER = "RELOADER";
+ private Reloader reloader = new Reloader();
+
public GFTestApp() {
super(GFTestResource.class);
+ register(reloader);
+
property(CommonProperties.PROVIDER_DEFAULT_DISABLE, "ALL");
+ property(RELOADER, reloader);
+ }
+
+ static class Reloader implements ContainerLifecycleListener {
+ Container container;
+
+ @Override
+ public void onStartup(Container container) {
+ this.container = container;
+ }
+
+ @Override
+ public void onReload(Container container) {
+
+ }
+
+ @Override
+ public void onShutdown(Container container) {
+
+ }
}
}
diff --git a/tests/integration/cdi-integration/gf-cdi-inject/src/main/java/org/glassfish/jersey/tests/cdi/gf/GFTestResource.java b/tests/integration/cdi-integration/gf-cdi-inject/src/main/java/org/glassfish/jersey/tests/cdi/gf/GFTestResource.java
index 2664778..b40830a 100644
--- a/tests/integration/cdi-integration/gf-cdi-inject/src/main/java/org/glassfish/jersey/tests/cdi/gf/GFTestResource.java
+++ b/tests/integration/cdi-integration/gf-cdi-inject/src/main/java/org/glassfish/jersey/tests/cdi/gf/GFTestResource.java
@@ -20,6 +20,8 @@
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.Application;
+import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.UriInfo;
@@ -34,4 +36,12 @@
public String info() {
return uriInfo.getBaseUri().toASCIIString();
}
+
+ @GET
+ @Path("reload")
+ public String reload(@Context Application application) {
+ GFTestApp.Reloader reloader = (GFTestApp.Reloader) application.getProperties().get(GFTestApp.RELOADER);
+ reloader.container.reload();
+ return GFTestApp.RELOADER;
+ }
}
diff --git a/tests/integration/cdi-integration/gf-cdi-inject/src/test/java/org/glassfish/jersey/tests/cdi/gf/GFTest.java b/tests/integration/cdi-integration/gf-cdi-inject/src/test/java/org/glassfish/jersey/tests/cdi/gf/GFTest.java
index fc3ea3a..a224bc8 100644
--- a/tests/integration/cdi-integration/gf-cdi-inject/src/test/java/org/glassfish/jersey/tests/cdi/gf/GFTest.java
+++ b/tests/integration/cdi-integration/gf-cdi-inject/src/test/java/org/glassfish/jersey/tests/cdi/gf/GFTest.java
@@ -47,12 +47,27 @@
@Test
public void testUriInfo() {
- int port = Integer.parseInt(System.getProperty("webServerPort"));
- try (Response response = ClientBuilder.newClient().target("http://localhost:" + port).path("gf-test/test/info").request().get()) {
+ try (Response response = ClientBuilder.newClient().target("http://localhost:" + port())
+ .path("gf-test/test/info").request().get()) {
String entity = response.readEntity(String.class);
System.out.println(entity);
Assertions.assertEquals(200, response.getStatus());
Assertions.assertTrue(entity.contains("gf-test/test"));
}
}
+
+ @Test
+ public void testReload() {
+ try (Response response = ClientBuilder.newClient().target("http://localhost:" + port())
+ .path("gf-test/test/reload").request().get()) {
+ Assertions.assertEquals(200, response.getStatus());
+ Assertions.assertEquals(GFTestApp.RELOADER, response.readEntity(String.class));
+ }
+ testUriInfo();
+ }
+
+ private static int port() {
+ int port = Integer.parseInt(System.getProperty("webServerPort"));
+ return port;
+ }
}