Skip to content

Commit 51ecfb9

Browse files
committed
Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
1 parent da7c5c5 commit 51ecfb9

File tree

9 files changed

+302
-3
lines changed

9 files changed

+302
-3
lines changed

ext/cdi/jersey-cdi1x/src/main/java/org/glassfish/jersey/ext/cdi1x/internal/CdiComponentProvider.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2018 Payara Foundation and/or its affiliates. All rights reserved.
44
*
55
* This program and the accompanying materials are made available under the
@@ -75,6 +75,7 @@
7575
import org.glassfish.jersey.internal.inject.AbstractBinder;
7676
import org.glassfish.jersey.internal.inject.Binder;
7777
import org.glassfish.jersey.internal.inject.Bindings;
78+
import org.glassfish.jersey.internal.inject.CustomAnnotationLiteral;
7879
import org.glassfish.jersey.internal.inject.ForeignRequestScopeBridge;
7980
import org.glassfish.jersey.internal.inject.InjectionManager;
8081
import org.glassfish.jersey.internal.inject.InstanceBinding;
@@ -306,7 +307,8 @@ public boolean bind(final Class<?> clazz, final Set<Class<?>> providerContracts)
306307
? new RequestScopedCdiBeanSupplier(clazz, injectionManager, beanManager, isCdiManaged)
307308
: new GenericCdiBeanSupplier(clazz, injectionManager, beanManager, isCdiManaged);
308309

309-
SupplierInstanceBinding<AbstractCdiBeanSupplier> builder = Bindings.supplier(beanFactory).to(clazz);
310+
SupplierInstanceBinding<AbstractCdiBeanSupplier> builder = Bindings.supplier(beanFactory)
311+
.to(clazz).qualifiedBy(CustomAnnotationLiteral.INSTANCE);
310312
for (final Class contract : providerContracts) {
311313
builder.to(contract);
312314
}

tests/integration/jersey-3670/pom.xml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved.
5+
6+
This program and the accompanying materials are made available under the
7+
terms of the Eclipse Public License v. 2.0, which is available at
8+
http://www.eclipse.org/legal/epl-2.0.
9+
10+
This Source Code may also be made available under the following Secondary
11+
Licenses when the conditions for such availability set forth in the
12+
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
13+
version 2 with the GNU Classpath Exception, which is available at
14+
https://www.gnu.org/software/classpath/license.html.
15+
16+
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
17+
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<parent>
24+
<groupId>org.glassfish.jersey.tests.integration</groupId>
25+
<artifactId>project</artifactId>
26+
<version>2.29-SNAPSHOT</version>
27+
</parent>
28+
29+
<artifactId>jersey-3670</artifactId>
30+
<packaging>war</packaging>
31+
<name>jersey-tests-integration-jersey-3670</name>
32+
33+
<description>JERSEY-3670 - Broken ParamConverterProvider ordering in 2.26</description>
34+
35+
<dependencies>
36+
<dependency>
37+
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
38+
<artifactId>jersey-test-framework-provider-external</artifactId>
39+
<scope>test</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>javax.validation</groupId>
43+
<artifactId>validation-api</artifactId>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.glassfish.jersey.connectors</groupId>
47+
<artifactId>jersey-grizzly-connector</artifactId>
48+
<scope>test</scope>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
52+
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
53+
<scope>test</scope>
54+
</dependency>
55+
</dependencies>
56+
57+
<build>
58+
<plugins>
59+
<plugin>
60+
<groupId>org.apache.maven.plugins</groupId>
61+
<artifactId>maven-compiler-plugin</artifactId>
62+
</plugin>
63+
</plugins>
64+
</build>
65+
66+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
package org.glassfish.jersey.tests.integration.i3670;
18+
19+
import javax.ws.rs.core.Application;
20+
import java.util.LinkedHashSet;
21+
import java.util.Set;
22+
23+
public class MyApplication extends Application {
24+
25+
@Override
26+
public Set<Class<?>> getClasses() {
27+
LinkedHashSet<Class<?>> classes = new LinkedHashSet<>();
28+
classes.add(MyResource.class);
29+
classes.add(MyConverterProvider.class);
30+
return classes;
31+
}
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
package org.glassfish.jersey.tests.integration.i3670;
18+
19+
import javax.annotation.Priority;
20+
import javax.ws.rs.ext.ParamConverter;
21+
import javax.ws.rs.ext.ParamConverterProvider;
22+
import java.lang.annotation.Annotation;
23+
import java.lang.reflect.Type;
24+
25+
@Priority(0)
26+
public class MyConverterProvider implements ParamConverterProvider {
27+
28+
@Override
29+
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {
30+
31+
if (rawType.equals(Integer.class)) {
32+
33+
/*
34+
* Dummy ParamConverter which always returns "42".
35+
*/
36+
return (ParamConverter<T>) new ParamConverter<Integer>() {
37+
@Override
38+
public Integer fromString(String value) {
39+
return 42;
40+
}
41+
42+
@Override
43+
public String toString(Integer value) {
44+
throw new UnsupportedOperationException();
45+
}
46+
};
47+
48+
}
49+
return null;
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
package org.glassfish.jersey.tests.integration.i3670;
18+
19+
import javax.validation.executable.ExecutableType;
20+
import javax.validation.executable.ValidateOnExecution;
21+
import javax.ws.rs.GET;
22+
import javax.ws.rs.Path;
23+
import javax.ws.rs.PathParam;
24+
25+
@Path("/param/{value}")
26+
@ValidateOnExecution(type = ExecutableType.NONE)
27+
public class MyResource {
28+
29+
@PathParam("value")
30+
private Integer value;
31+
32+
@GET
33+
public String get() {
34+
return "Value injected via @PathParam: " + value;
35+
}
36+
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved.
5+
6+
This program and the accompanying materials are made available under the
7+
terms of the Eclipse Public License v. 2.0, which is available at
8+
http://www.eclipse.org/legal/epl-2.0.
9+
10+
This Source Code may also be made available under the following Secondary
11+
Licenses when the conditions for such availability set forth in the
12+
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
13+
version 2 with the GNU Classpath Exception, which is available at
14+
https://www.gnu.org/software/classpath/license.html.
15+
16+
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
17+
18+
-->
19+
20+
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
23+
bean-discovery-mode="all">
24+
</beans>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<!--
3+
4+
Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved.
5+
6+
This program and the accompanying materials are made available under the
7+
terms of the Eclipse Public License v. 2.0, which is available at
8+
http://www.eclipse.org/legal/epl-2.0.
9+
10+
This Source Code may also be made available under the following Secondary
11+
Licenses when the conditions for such availability set forth in the
12+
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
13+
version 2 with the GNU Classpath Exception, which is available at
14+
https://www.gnu.org/software/classpath/license.html.
15+
16+
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
17+
18+
-->
19+
20+
<html lang="en">
21+
<head>
22+
<meta charset="UTF-8">
23+
<title>Jersey Provider Priority (issue 3670)</title>
24+
</head>
25+
<body>
26+
<h1>Jersey Provider Priority (issue 3670)</h1>
27+
28+
<ul>
29+
<li>
30+
<a href="./r/param/1">
31+
./r/param/1
32+
</a>
33+
</li>
34+
</ul>
35+
</body>
36+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
package org.glassfish.jersey.tests.integration.i3670;
18+
19+
import org.glassfish.jersey.test.JerseyTest;
20+
import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory;
21+
import org.glassfish.jersey.test.spi.TestContainerException;
22+
import org.glassfish.jersey.test.spi.TestContainerFactory;
23+
import org.junit.Test;
24+
25+
import javax.ws.rs.core.Application;
26+
27+
import static org.junit.Assert.assertEquals;
28+
29+
public class ExternalApplicationParamConverterTest extends JerseyTest {
30+
31+
private static final String CHECK_STRING = "Value injected via @PathParam: 42";
32+
33+
@Override
34+
protected Application configure() {
35+
return new MyApplication();
36+
}
37+
38+
@Override
39+
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
40+
return new GrizzlyTestContainerFactory();
41+
}
42+
43+
@Test
44+
public void testExternalParamConverterValue() {
45+
final String resp = target("/param/1").request().get(String.class);
46+
assertEquals(CHECK_STRING, resp);
47+
}
48+
49+
}

tests/integration/pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved.
55
Copyright (c) 2018 Payara Foundation and/or its affiliates. All rights reserved.
66
77
This program and the accompanying materials are made available under the
@@ -86,6 +86,7 @@
8686
<module>jersey-2878</module>
8787
<module>jersey-2892</module>
8888
<module>jersey-780</module>
89+
<module>jersey-3670</module>
8990
<module>jersey-3992</module>
9091
<module>portability-jersey-1</module>
9192
<module>portability-jersey-2</module>

0 commit comments

Comments
 (0)