Use just the latest Weld and fix CDI-BV module Signed-off-by: Jan Supol <jan.supol@oracle.com>
diff --git a/examples/helloworld-cdi2-se/pom.xml b/examples/helloworld-cdi2-se/pom.xml index 683854b..fe406f4 100644 --- a/examples/helloworld-cdi2-se/pom.xml +++ b/examples/helloworld-cdi2-se/pom.xml
@@ -26,10 +26,6 @@ <description>Jersey "Hello world" example with CDI 2 SE.</description> - <properties> - <weld.version>${weld3.version}</weld.version> - </properties> - <dependencies> <dependency> <groupId>org.glassfish.jersey.inject</groupId>
diff --git a/ext/bean-validation/src/main/java/org/glassfish/jersey/server/validation/internal/ValidationInterceptorExecutor.java b/ext/bean-validation/src/main/java/org/glassfish/jersey/server/validation/internal/ValidationInterceptorExecutor.java index d50d557..9b40473 100644 --- a/ext/bean-validation/src/main/java/org/glassfish/jersey/server/validation/internal/ValidationInterceptorExecutor.java +++ b/ext/bean-validation/src/main/java/org/glassfish/jersey/server/validation/internal/ValidationInterceptorExecutor.java
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020 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 @@ -81,7 +81,12 @@ @Override public void setArgs(final Object[] args) { - this.args = args; + if (args.length == this.args.length) { + // Replace the original arguments with the new ones + System.arraycopy(args, 0, this.args, 0, args.length); + } else { + this.args = args; + } } @Override
diff --git a/ext/cdi/jersey-cdi1x-validation/pom.xml b/ext/cdi/jersey-cdi1x-validation/pom.xml index 6de36ec..ca18f38 100644 --- a/ext/cdi/jersey-cdi1x-validation/pom.xml +++ b/ext/cdi/jersey-cdi1x-validation/pom.xml
@@ -47,6 +47,13 @@ </dependency> <dependency> + <groupId>org.glassfish.jersey.ext.cdi</groupId> + <artifactId>jersey-cdi1x</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> <groupId>jakarta.enterprise</groupId> <artifactId>jakarta.enterprise.cdi-api</artifactId> <scope>provided</scope> @@ -54,10 +61,6 @@ <!-- Remove ancient jakarta.el that causes problems with Hibernate --> <exclusion> <groupId>jakarta.el</groupId> - <artifactId>el-api</artifactId> - </exclusion> - <exclusion> - <groupId>jakarta.el</groupId> <artifactId>jakarta.el-api</artifactId> </exclusion> </exclusions>
diff --git a/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapper.java b/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapper.java index bf3077d..835e0ca 100644 --- a/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapper.java +++ b/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapper.java
@@ -60,13 +60,13 @@ @AroundInvoke public Object validateMethodInvocation(InvocationContext ctx) throws Exception { - final boolean isJaxRsMethod = extension.jaxRsResourceCache.apply(ctx.getMethod().getDeclaringClass()); + final boolean isJaxRsMethod = extension.getJaxRsResourceCache().apply(ctx.getMethod().getDeclaringClass()); return isJaxRsMethod ? ctx.proceed() : interceptor.validateMethodInvocation(ctx); } @AroundConstruct public void validateConstructorInvocation(InvocationContext ctx) throws Exception { - final boolean isJaxRsConstructor = extension.jaxRsResourceCache.apply(ctx.getConstructor().getDeclaringClass()); + final boolean isJaxRsConstructor = extension.getJaxRsResourceCache().apply(ctx.getConstructor().getDeclaringClass()); if (!isJaxRsConstructor) { interceptor.validateConstructorInvocation(ctx); }
diff --git a/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapperExtension.java b/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapperExtension.java index 6e0dbf6..fd77465 100644 --- a/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapperExtension.java +++ b/ext/cdi/jersey-cdi1x-validation/src/main/java/org/glassfish/jersey/ext/cdi1x/validation/internal/CdiInterceptorWrapperExtension.java
@@ -40,6 +40,7 @@ import jakarta.enterprise.util.AnnotationLiteral; import jakarta.interceptor.Interceptor; +import org.glassfish.jersey.ext.cdi1x.internal.JerseyVetoed; import org.glassfish.jersey.internal.util.collection.Cache; import org.glassfish.jersey.server.model.Resource; @@ -51,12 +52,13 @@ * @author Jakub Podlesak */ @Priority(value = Interceptor.Priority.PLATFORM_BEFORE + 199) +@JerseyVetoed public class CdiInterceptorWrapperExtension implements Extension { public static final AnnotationLiteral<Default> DEFAULT_ANNOTATION_LITERAL = new AnnotationLiteral<Default>() {}; public static final AnnotationLiteral<Any> ANY_ANNOTATION_LITERAL = new AnnotationLiteral<Any>() {}; - final Cache<Class<?>, Boolean> jaxRsResourceCache = new Cache<>(clazz -> Resource.from(clazz) != null); + private Cache<Class<?>, Boolean> jaxRsResourceCache = new Cache<>(clazz -> Resource.from(clazz) != null); private AnnotatedType<ValidationInterceptor> interceptorAnnotatedType; @@ -82,7 +84,10 @@ * @param afterTypeDiscovery CDI bootstrap event. */ private void afterTypeDiscovery(@Observes final AfterTypeDiscovery afterTypeDiscovery) { - afterTypeDiscovery.getInterceptors().removeIf(ValidationInterceptor.class::equals); + // Does throw java.lang.IndexOutOfBoundsException in Weld 4 + // afterTypeDiscovery.getInterceptors().removeIf(ValidationInterceptor.class::equals); + // iterator.remove throws as well + afterTypeDiscovery.getInterceptors().remove(ValidationInterceptor.class); } /** @@ -171,4 +176,12 @@ } }); } + + /* package */ Cache<Class<?>, Boolean> getJaxRsResourceCache() { + /* CDI injection hack */ + if (jaxRsResourceCache == null) { + jaxRsResourceCache = new Cache<>(clazz -> Resource.from(clazz) != null); + } + return jaxRsResourceCache; + } }
diff --git a/inject/cdi2-se/pom.xml b/inject/cdi2-se/pom.xml index 6756ef9..4c95643 100644 --- a/inject/cdi2-se/pom.xml +++ b/inject/cdi2-se/pom.xml
@@ -42,7 +42,6 @@ <dependency> <groupId>org.jboss.weld.se</groupId> <artifactId>weld-se-core</artifactId> - <version>${weld3.version}</version> </dependency> <dependency>
diff --git a/pom.xml b/pom.xml index 7e82e3a..ffe6645 100644 --- a/pom.xml +++ b/pom.xml
@@ -2118,18 +2118,16 @@ <spring5.version>5.1.5.RELEASE</spring5.version> <surefire.version>3.0.0-M3</surefire.version> - <weld.version>2.2.14.Final</weld.version> <!-- 2.4.1 doesn't work - bv tests --> + <weld.version>4.0.0.Beta1</weld.version> <!-- 2.4.1 doesn't work - bv tests --> <!-- Jakartified, eligible for CQ --> - <validation.impl.version>7.0.0.Alpha1</validation.impl.version> - <weld3.version>4.0.0.Alpha2</weld3.version> - <weld4.version>4.0.0.Alpha2</weld4.version> + <validation.impl.version>7.0.0.Alpha6</validation.impl.version> <!-- END of Jakartified, eligible for CQ --> <xerces.version>2.11.0</xerces.version> <!-- do not need CQs (below this line till the end of version properties)--> <gf.impl.version>5.1.0</gf.impl.version> <!-- Jakartified --> - <cdi.api.version>3.0.0-M4</cdi.api.version> + <cdi.api.version>3.0.0</cdi.api.version> <ejb.version>4.0.0-RC2</ejb.version> <grizzly2.version>3.0.0-M1</grizzly2.version> <hk2.version>3.0.0-M2</hk2.version>
diff --git a/tests/e2e-inject/cdi2-se/pom.xml b/tests/e2e-inject/cdi2-se/pom.xml index 9eaaac2..a3bcba1 100644 --- a/tests/e2e-inject/cdi2-se/pom.xml +++ b/tests/e2e-inject/cdi2-se/pom.xml
@@ -32,10 +32,6 @@ <description>Jersey E2E Inject CDI SE tests</description> - <properties> - <weld.version>${weld3.version}</weld.version> - </properties> - <dependencies> <dependency> <groupId>org.glassfish.jersey.inject</groupId>
diff --git a/tests/integration/JERSEY-2988/pom.xml b/tests/integration/JERSEY-2988/pom.xml index 5775685..ea11488 100644 --- a/tests/integration/JERSEY-2988/pom.xml +++ b/tests/integration/JERSEY-2988/pom.xml
@@ -66,7 +66,6 @@ <dependency> <groupId>org.jboss.weld.servlet</groupId> <artifactId>weld-servlet-core</artifactId> - <version>${weld3.version}</version> </dependency> </dependencies>
diff --git a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/pom.xml b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/pom.xml index a71cc97..53ac307 100644 --- a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/pom.xml +++ b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/pom.xml
@@ -124,20 +124,5 @@ </profiles> <build> <finalName>${project.artifactId}</finalName> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <forkMode>always</forkMode> - <enableAssertions>false</enableAssertions> - <!-- TODO remove after jakartification --> - <excludes> - <exclude>org/glassfish/jersey/tests/cdi/bv/CombinedTest.java</exclude> - <exclude>org/glassfish/jersey/tests/cdi/bv/RawCdiTest.java</exclude> - </excludes> - </configuration> - </plugin> - </plugins> </build> </project>
diff --git a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/main/java/org/glassfish/jersey/tests/cdi/bv/CdiValidationInterceptor.java b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/main/java/org/glassfish/jersey/tests/cdi/bv/CdiValidationInterceptor.java index 492cafe..5fe2dac 100644 --- a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/main/java/org/glassfish/jersey/tests/cdi/bv/CdiValidationInterceptor.java +++ b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/main/java/org/glassfish/jersey/tests/cdi/bv/CdiValidationInterceptor.java
@@ -16,17 +16,16 @@ package org.glassfish.jersey.tests.cdi.bv; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.validation.ConstraintViolationException; import jakarta.validation.ValidationException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + import org.glassfish.jersey.server.spi.ValidationInterceptor; import org.glassfish.jersey.server.spi.ValidationInterceptorContext; - import org.jboss.weld.interceptor.util.proxy.TargetInstanceProxy; /** @@ -66,7 +65,7 @@ final Object resource = ctx.getResource(); if (resource instanceof TargetInstanceProxy) { - ctx.setResource(((TargetInstanceProxy) resource).getTargetInstance()); + ctx.setResource(((TargetInstanceProxy) resource).weld_getTargetInstance()); } try { @@ -79,6 +78,7 @@ ValidationResultUtil.updateValidationResultProperty(resource, validationResultGetter, constraintViolationException.getConstraintViolations()); pir.setValidationResult(validationResult); + ctx.getArgs()[0] = ""; // Let it not be null } else { // Then check for a field final Field vr = ValidationResultUtil.getValidationResultField(resource); @@ -88,6 +88,7 @@ } else { if (isValidationResultInArgs(ctx.getArgs())) { this.validationResult.setViolations(constraintViolationException.getConstraintViolations()); + ctx.getArgs()[0] = ""; // Let it not be null } else { throw constraintViolationException; }
diff --git a/tests/integration/cdi-integration/cdi-log-check/pom.xml b/tests/integration/cdi-integration/cdi-log-check/pom.xml index 07e03b7..a7d6df7 100644 --- a/tests/integration/cdi-integration/cdi-log-check/pom.xml +++ b/tests/integration/cdi-integration/cdi-log-check/pom.xml
@@ -110,22 +110,5 @@ <maven.test.skip>false</maven.test.skip> </properties> </profile> - <profile> - <id>jakartification_exclude_tests</id> <!-- TODO remove after jakartification --> - <activation> - <jdk>[1.8,)</jdk> - </activation> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <skipTests>true</skipTests> - </configuration> - </plugin> - </plugins> - </build> - </profile> </profiles> </project>
diff --git a/tests/integration/cdi-integration/cdi-manually-bound/pom.xml b/tests/integration/cdi-integration/cdi-manually-bound/pom.xml index e6e068e..39f9be0 100644 --- a/tests/integration/cdi-integration/cdi-manually-bound/pom.xml +++ b/tests/integration/cdi-integration/cdi-manually-bound/pom.xml
@@ -40,7 +40,6 @@ <dependency> <groupId>jakarta.enterprise</groupId> <artifactId>jakarta.enterprise.cdi-api</artifactId> -<!-- <version>3.0.0-M2</version>--> </dependency> <dependency> <groupId>org.glassfish.jersey.ext.cdi</groupId> @@ -49,7 +48,6 @@ <dependency> <groupId>org.jboss.weld.se</groupId> <artifactId>weld-se-core</artifactId> - <version>4.0.0.Alpha1</version> <scope>test</scope> </dependency> <dependency>
diff --git a/tests/integration/cdi-integration/cdi-test-webapp/pom.xml b/tests/integration/cdi-integration/cdi-test-webapp/pom.xml index 6737efb..cd39f50 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/pom.xml +++ b/tests/integration/cdi-integration/cdi-test-webapp/pom.xml
@@ -93,22 +93,5 @@ <maven.test.skip>false</maven.test.skip> </properties> </profile> - <profile> - <id>jakartification_exclude_tests</id> <!-- TODO remove after jakartification --> - <activation> - <jdk>[1.8,)</jdk> - </activation> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <skipTests>true</skipTests> - </configuration> - </plugin> - </plugins> - </build> - </profile> </profiles> </project>