eclipse-ee4j / eclipse-ee4j/jersey

Jersey client crashes on curly brackets

Open
#3,347 3 comments 0 reactions 0 assignees View on GitHub
Component: core Priority: Major Type: Bug
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

When using jersey as a client for a webservice that has some query parameters of type string and such a value contains curly brackets {}, the client will throw an exception.

Consider the following service being proxied;
@Path("/service")
public interface SomeService

{ @GET @Path("/operation") public SomeServiceResponse someoperation(@QueryParam("parameter") String parameter); }

Currently callers have a responsibility to URI encode the "parameter" value when using this service to prevent the template parsing from activating.

This is inconvenient and also not logical as the caller is not (and should not be) concerned whether this is a remote REST service via jersey or just some local implementation of the interface.

I propose that, at least for the jersey-proxy-client, all parameters are always output as they are and no attempt is done to apply templates.
This on/off behaviour could then be controlled via settings at construction time when generating the proxy if necessary, for example when doing the WebResourceFactory.newResource call

The exception that is returned is similar to:

Caused by: java.lang.IllegalArgumentException: Illegal character "3" at position 91 is not allowed after a name in a path template
at org.glassfish.jersey.uri.internal.UriTemplateParser.parseName(UriTemplateParser.java:360)
at org.glassfish.jersey.uri.internal.UriTemplateParser.parse(UriTemplateParser.java:255)
at org.glassfish.jersey.uri.internal.UriTemplateParser.(UriTemplateParser.java:114)
at org.glassfish.jersey.uri.UriTemplate.createUriComponent(UriTemplate.java:1004)
at org.glassfish.jersey.uri.UriTemplate.createURIWithStringValues(UriTemplate.java:970)
at org.glassfish.jersey.uri.UriTemplate.createURIWithStringValues(UriTemplate.java:906)
at org.glassfish.jersey.uri.UriTemplate.createURI(UriTemplate.java:871)
at org.glassfish.jersey.uri.internal.JerseyUriBuilder._build(JerseyUriBuilder.java:914)
at org.glassfish.jersey.uri.internal.JerseyUriBuilder.build(JerseyUriBuilder.java:831)
at org.glassfish.jersey.client.JerseyWebTarget.getUri(JerseyWebTarget.java:132)
#### Affected Versions
[2.22.2]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.