Skip to content

UriTemplate Does not handle composite values #483

@JamesTPF

Description

@JamesTPF

We're connecting to a service which returns URI's in the following form:
http://someserver.net/models?makeId=bbb9fdae593d5ce834a979f3c5f0437c{&id*,aPacks*,dataIssue}
where an '*' responds to a composite value:
https://tools.ietf.org/html/rfc6570#section-2.4.2

The regex in the UriTemplate cannot handle the '*' at the end of the template name.

private static final Pattern VARIABLE_REGEX = Pattern.compile("\\{([\\?\\&#/]?)([\\w\\,]+)\\}");

Can this regex get changed to:

private static final Pattern VARIABLE_REGEX = Pattern.compile("\\{([\\?\\&#/]?)([\\w\\,*]+)\\}");

?

Otherwise we end up with the following exception:

java.lang.IllegalArgumentException: Illegal character in query at index 101: XXXXXXXXX
    at java.net.URI.create(URI.java:852)
    at org.springframework.hateoas.UriTemplate.expand(UriTemplate.java:219)
    at org.springframework.hateoas.client.Traverson$TraversalBuilder.traverseToFinalUrl(Traverson.java:384)
    at org.springframework.hateoas.client.Traverson$TraversalBuilder.toObject(Traverson.java:321)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions