Skip to content

Commit cd910d7

Browse files
committed
Fix query param in UriBuilder
Signed-off-by: jansupol <jan.supol@oracle.com>
1 parent ab217b3 commit cd910d7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ private static String createURI(
887887
offset, encode, mapValues, sb);
888888
if (sb.length() > sbLength) {
889889
char firstQuery = sb.charAt(sbLength);
890-
if (firstQuery != '?' && firstQuery != '&') {
890+
if (firstQuery != '?' && (!query.trim().startsWith("{") || firstQuery != '&')) {
891891
sb.insert(sbLength, '?');
892892
}
893893
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,17 @@ public void testQueryParamStyleMultiPairs() {
16591659
"key1=val1&key1=val2&key2=val1&key1=val3");
16601660
}
16611661

1662+
1663+
@Test
1664+
public void testQueryParam() {
1665+
URI uri = new JerseyUriBuilder().scheme("http").host("localhost").port(8080).uri("some")
1666+
.replacePath("NewPath")
1667+
.replaceQuery("&Second")
1668+
.build();
1669+
Assertions.assertEquals("&Second", uri.getQuery());
1670+
}
1671+
1672+
16621673
@Test
16631674
void testFragment5269() throws URISyntaxException {
16641675
final URI uri = new URI("http://www.example.org/foo.xml#xpointer(//Rube)").normalize();

0 commit comments

Comments
 (0)