Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 7163b4f

Browse files
author
Adam Lindenthal
committed
Merge pull request #89 from TheJoeMoore/master
Fix and test for JERSEY-2556 - issue with JerseyUriBuilder.path and generic methods
2 parents 87ea0d7 + a7d48d5 commit 7163b4f

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

core-common/src/main/java/org/glassfish/jersey/uri/internal/JerseyUriBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ public JerseyUriBuilder path(Class resource, String methodName) {
376376
Method found = null;
377377
for (Method m : methods) {
378378
if (methodName.equals(m.getName())) {
379-
if (found == null) {
379+
if (found == null || found.isSynthetic()) {
380380
found = m;
381-
} else {
381+
} else if (!m.isSynthetic()) {
382382
throw new IllegalArgumentException();
383383
}
384384
}

core-common/src/test/java/org/glassfish/jersey/uri/internal/JerseyUriBuilderTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
import javax.ws.rs.GET;
5353
import javax.ws.rs.Path;
54+
import javax.ws.rs.PathParam;
5455
import javax.ws.rs.core.MultivaluedMap;
5556
import javax.ws.rs.core.PathSegment;
5657
import javax.ws.rs.core.UriBuilder;
@@ -1108,6 +1109,28 @@ public void testResourceWithTemplateRegexAppendPath() throws NoSuchMethodExcepti
11081109
Assert.assertEquals(URI.create("http://localhost:8080/base/method/foo/locator/bar"), ub);
11091110
}
11101111

1112+
interface GenericInterface<T, U> {
1113+
T find (U u);
1114+
}
1115+
1116+
@Path("resource/")
1117+
class ResourceWithGenericInterface implements GenericInterface<Object, String> {
1118+
1119+
@GET
1120+
@Path("{id}")
1121+
@Override
1122+
public Object find(@PathParam("id") String s) {
1123+
return null;
1124+
}
1125+
}
1126+
1127+
@Test
1128+
public void testResourceWithGenericInterfaceAppendPath() {
1129+
URI ub = UriBuilder.fromUri("http://localhost:8080/base")
1130+
.path(ResourceWithGenericInterface.class, "find").build("foo");
1131+
Assert.assertEquals(URI.create("http://localhost:8080/base/foo"), ub);
1132+
}
1133+
11111134
@Test
11121135
public void testBuildTemplates() {
11131136
URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").

0 commit comments

Comments
 (0)