diff --git a/examples/helloworld-cdi2-se/pom.xml b/examples/helloworld-cdi2-se/pom.xml index 683854b176..fe406f412a 100644 --- a/examples/helloworld-cdi2-se/pom.xml +++ b/examples/helloworld-cdi2-se/pom.xml @@ -26,10 +26,6 @@ Jersey "Hello world" example with CDI 2 SE. - - ${weld3.version} - - org.glassfish.jersey.inject 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 d50d557d07..9b404735c2 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 @@ public Object[] getArgs() { @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 6de36ec9b0..ca18f388a1 100644 --- a/ext/cdi/jersey-cdi1x-validation/pom.xml +++ b/ext/cdi/jersey-cdi1x-validation/pom.xml @@ -46,16 +46,19 @@ provided + + org.glassfish.jersey.ext.cdi + jersey-cdi1x + ${project.version} + provided + + jakarta.enterprise jakarta.enterprise.cdi-api provided - - jakarta.el - el-api - jakarta.el jakarta.el-api 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 bf3077d05f..835e0ca78a 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 @@ public CdiInterceptorWrapper(BeanManager beanManager) { @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 6e0dbf6660..fd77465aa6 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_ANNOTATION_LITERAL = new AnnotationLiteral() {}; public static final AnnotationLiteral ANY_ANNOTATION_LITERAL = new AnnotationLiteral() {}; - final Cache, Boolean> jaxRsResourceCache = new Cache<>(clazz -> Resource.from(clazz) != null); + private Cache, Boolean> jaxRsResourceCache = new Cache<>(clazz -> Resource.from(clazz) != null); private AnnotatedType interceptorAnnotatedType; @@ -82,7 +84,10 @@ private void beforeBeanDiscovery(@Observes BeforeBeanDiscovery beforeBeanDiscove * @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 @@ public void destroy(ValidationInterceptor instance, } }); } + + /* package */ Cache, 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 6756ef9837..4c95643bda 100644 --- a/inject/cdi2-se/pom.xml +++ b/inject/cdi2-se/pom.xml @@ -42,7 +42,6 @@ org.jboss.weld.se weld-se-core - ${weld3.version} diff --git a/pom.xml b/pom.xml index 7e82e3a39f..ffe6645979 100644 --- a/pom.xml +++ b/pom.xml @@ -2118,18 +2118,16 @@ 5.1.5.RELEASE 3.0.0-M3 - 2.2.14.Final + 4.0.0.Beta1 - 7.0.0.Alpha1 - 4.0.0.Alpha2 - 4.0.0.Alpha2 + 7.0.0.Alpha6 2.11.0 5.1.0 - 3.0.0-M4 + 3.0.0 4.0.0-RC2 3.0.0-M1 3.0.0-M2 diff --git a/tests/e2e-inject/cdi2-se/pom.xml b/tests/e2e-inject/cdi2-se/pom.xml index 9eaaac25fc..a3bcba1570 100644 --- a/tests/e2e-inject/cdi2-se/pom.xml +++ b/tests/e2e-inject/cdi2-se/pom.xml @@ -32,10 +32,6 @@ Jersey E2E Inject CDI SE tests - - ${weld3.version} - - org.glassfish.jersey.inject diff --git a/tests/integration/JERSEY-2988/pom.xml b/tests/integration/JERSEY-2988/pom.xml index 5775685165..ea114884b7 100644 --- a/tests/integration/JERSEY-2988/pom.xml +++ b/tests/integration/JERSEY-2988/pom.xml @@ -66,7 +66,6 @@ org.jboss.weld.servlet weld-servlet-core - ${weld3.version} diff --git a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/pom.xml b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/pom.xml index a71cc973bf..53ac30788a 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 @@ ${project.artifactId} - - - org.apache.maven.plugins - maven-surefire-plugin - - always - false - - - org/glassfish/jersey/tests/cdi/bv/CombinedTest.java - org/glassfish/jersey/tests/cdi/bv/RawCdiTest.java - - - - 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 492cafedaa..5fe2dac75f 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 @@ public void onValidate(ValidationInterceptorContext ctx) throws ValidationExcept 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 @@ public void onValidate(ValidationInterceptorContext ctx) throws ValidationExcept 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 @@ public void onValidate(ValidationInterceptorContext ctx) throws ValidationExcept } 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 07e03b7605..a7d6df7e10 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 @@ false - - jakartification_exclude_tests - - [1.8,) - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - - diff --git a/tests/integration/cdi-integration/cdi-manually-bound/pom.xml b/tests/integration/cdi-integration/cdi-manually-bound/pom.xml index e6e068e6a9..39f9be0dab 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 @@ jakarta.enterprise jakarta.enterprise.cdi-api - org.glassfish.jersey.ext.cdi @@ -49,7 +48,6 @@ org.jboss.weld.se weld-se-core - 4.0.0.Alpha1 test diff --git a/tests/integration/cdi-integration/cdi-test-webapp/pom.xml b/tests/integration/cdi-integration/cdi-test-webapp/pom.xml index 6737efb118..cd39f50fb6 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 @@ false - - jakartification_exclude_tests - - [1.8,) - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - -