Skip to content

Commit

Permalink
RESTEASY-2335 RestEasy Microprofile Client has a immutable template p… (
Browse files Browse the repository at this point in the history
#2166)

* RESTEASY-2335 RestEasy Microprofile Client has a immutable template problem/bug

* fix NPE
  • Loading branch information
liweinan authored and asoldano committed Sep 20, 2019
1 parent 2684fff commit d3e703d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
Expand Up @@ -364,22 +364,16 @@ private <T> void verifyInterface(Class<T> typeDef) {
// invalid parameter
Path classPathAnno = typeDef.getAnnotation(Path.class);

final Set<String> classLevelVariables = new HashSet<>();
ResteasyUriBuilder classTemplate = null;
if (classPathAnno != null) {
classTemplate = (ResteasyUriBuilder) UriBuilder.fromUri(classPathAnno.value());
classLevelVariables.addAll(classTemplate.getPathParamNamesInDeclarationOrder()); // TODO: doesn't seem to be used!
}
ResteasyUriBuilder template;
ResteasyUriBuilder template = null;
for (Method method : methods) {

Path methodPathAnno = method.getAnnotation(Path.class);
if (methodPathAnno != null) {
template = classPathAnno == null ? (ResteasyUriBuilder) UriBuilder.fromUri(methodPathAnno.value())
: (ResteasyUriBuilder) UriBuilder.fromUri(classPathAnno.value() + "/" + methodPathAnno.value());
} else {
template = classTemplate;
} else if (classPathAnno != null) {
template = (ResteasyUriBuilder) UriBuilder.fromUri(classPathAnno.value());
}

if (template == null) {
continue;
}
Expand Down
@@ -0,0 +1,15 @@
package org.jboss.resteasy.microprofile.client;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

@Path("/{id}")
public interface RESTEASY_2335_Resource {
@GET
String get(@PathParam("id") String id);

@POST
String post(@PathParam("id") String id);
}
@@ -0,0 +1,15 @@
package org.jboss.resteasy.microprofile.client;

import org.eclipse.microprofile.rest.client.RestClientBuilder;
import org.junit.Test;

import java.net.URI;

public class RESTEASY_2335_Test {
public static final String HTTP_LOCALHOST_8080 = "http://localhost:8080";

@Test
public void test2335() {
RestClientBuilder.newBuilder().baseUri(URI.create(HTTP_LOCALHOST_8080)).build(RESTEASY_2335_Resource.class);
}
}

0 comments on commit d3e703d

Please sign in to comment.