You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Jorge Cercas (Jira)" <ji...@apache.org> on 2019/11/12 17:47:00 UTC

[jira] [Comment Edited] (CXF-8153) @Path with REGEX in path parameter and checkMethodsForInvalidURITemplates(userType, methods);

    [ https://issues.apache.org/jira/browse/CXF-8153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16972657#comment-16972657 ] 

Jorge Cercas edited comment on CXF-8153 at 11/12/19 5:46 PM:
-------------------------------------------------------------

I have the exact same problem when using the CXF implementation of the _Rest Client for MicroProfile_ [*org.apache.cxf:cxf-rt-rs-mp-client:3.3.4*]. The exception is:
{quote}org.eclipse.microprofile.rest.client.RestClientDefinitionException: The client interface, interface microprofile.test.SomeResource has one or more methods with unresolved path template variables: public abstract javax.ws.rs.core.Response microprofile.test.SomeResource.update(java.util.UUID)
{quote}
the resource API is:

 
{code:java}
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("abc/{abcId}/xyz")
public interface SomeResource {

    @PUT
    @Path("{xyzId: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}}")
    Response updateStorage(@PathParam("xyzId") UUID xyzId);
}

{code}
with the following usage of MP rest client: 

 
{code:java}
RestClientBuilder
    .newBuilder()
    .baseUri(uri)
    .build(SomeResource.class);

{code}
 

+*Note:*+
 When swapping out the CXF with the RestEasy implemetation (*org.jboss.resteasy:resteasy-client-microprofile:4.4.0.Final*),  we do not observe the same behaviour, i.e.: no exceptions, all works "as expected".

 

 


was (Author: bokie):
I have the exact same problem when using the CXF implementation of the _Rest Client for MicroProfile_ [*org.apache.cxf:cxf-rt-rs-mp-client:3.3.4*]. The exception is: 

{quote}org.eclipse.microprofile.rest.client.RestClientDefinitionException: The client interface, interface microprofile.test.SomeResource has one or more methods with unresolved path template variables: public abstract javax.ws.rs.core.Response microprofile.test.SomeResource.update(java.util.UUID)
{quote}
the resource API is:
{code:java}

@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("abc/{abcId}/xyz")
public interface SomeResource {

    @PUT
    @Path("{xyzId: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}}")
    Response updateStorage(@PathParam("xyzId") UUID xyzId);
}

{code}
with the following usage of MP rest client: 
{code:java}

RestClientBuilder
    .newBuilder()
    .baseUri(uri)
    .build(SomeResource.class);

{code}
 

+*Note:*+
When swapping out the CXF with the RestEasy implemetation (*org.jboss.resteasy:resteasy-client-microprofile:4.4.0.Final*),  we do not observe the same behaviour, i.e.: no exceptions, all works "as expected".

 

 

>  @Path with REGEX in path parameter and checkMethodsForInvalidURITemplates(userType, methods);
> ----------------------------------------------------------------------------------------------
>
>                 Key: CXF-8153
>                 URL: https://issues.apache.org/jira/browse/CXF-8153
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.3.4
>            Reporter: Luís Alves
>            Priority: Minor
>
> I have an API jar provided by the server, with the interface with all the JAX-RS annotations.
> One of then has an REGEX. Something like:
> {code:java}
> @Path("{ resoureUUID : [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}}}")
> {code}
> I can't create a proxy because the validation fails. Analyzing the code I get to 
> org.apache.cxf.microprofile.client.Validator#checkMethodsForInvalidURITemplates(Class, Method[]), more specifically to this part (with comments):
> {code:java}
> for (Parameter p : method.getParameters()) {
>                     PathParam pathParam = p.getAnnotation(PathParam.class);
>                     if (pathParam != null) {
>                         // don't know the spec, but setting this to "x" cause the URITemplate to
>                        // throw new IllegalArgumentException("Value '" + sval + "' does not match variable " + var.getName() + " with pattern " + var.getPattern());
>                         paramMap.put(pathParam.value(), "x");
>                     }
>                 }
>                 try {
>                     template.substitute(paramMap, Collections.<String>emptySet(), false);
>                 } catch (IllegalArgumentException ex) {
>                     throwException("VALIDATION_UNRESOLVED_PATH_PARAMS", userType, method);
>                 }
> {code}
> Not sure if this is a bug or by spec, but this prevents to use path params with regex, as the only regex that works must match "x".



--
This message was sent by Atlassian Jira
(v8.3.4#803005)