andymc12 closed pull request #370: [CXF-7625] Handle schemeSpecificPart that
looks like host:port
URL: https://github.com/apache/cxf/pull/370
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
index 4e80a09c2e6..9eda94398d9 100644
---
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
+++
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
@@ -639,6 +639,10 @@ private void setUriParts(URI uri) {
} else {
schemeSpecificPart = uri.getSchemeSpecificPart();
}
+ if (scheme != null && host == null && (query == null ||
query.isEmpty()) && userInfo == null
+ && uri.getSchemeSpecificPart() != null) {
+ schemeSpecificPart = uri.getSchemeSpecificPart();
+ }
String theFragment = uri.getFragment();
if (theFragment != null) {
fragment = theFragment;
diff --git
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
index a50e111b953..2ed7dec0aaf 100644
---
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
+++
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
@@ -1606,6 +1606,37 @@ public void testFromMethod() {
assertEquals(uri.toString(), "/sub");
}
+ @Test
+ public void testURItoStringMatchesOriginalURI() {
+ String[] uriStrings = new String[]{"mailto:[email protected]",
+ "news:comp.lang.java",
+ "urn:isbn:096139210x",
+
"docs/guide/collections/designfaq.html#28",
+
"../../../demo/jfc/SwingSet2/src/SwingSet2.java",
+ "file:///~/calendar",
+ "[email protected]",
+ "http://localhost/somePath",
+
"http://localhost:1234/someOtherPath",
+ "http://127.0.0.1",
+ "http://127.0.0.1/",
+ "http://127.0.0.1/index.html",
+ "myscheme://a.host:7575/",
+
"myscheme://not.really.a.host:fakePort/"
+ };
+ for (String uriString :uriStrings) {
+ URI uri = UriBuilder.fromUri(uriString).build();
+ assertEquals(uriString, uri.toString());
+ }
+ }
+
+ @Test
+ public void testURIWithNonIntegerPort() {
+ String url = "myscheme://not.really.a.host:port/";
+ UriBuilder builder = UriBuilder.fromUri(url);
+ URI uri = builder.build();
+ assertEquals(url, uri.toString());
+ }
+
@Path(value = "/TestPath")
public static class TestPath {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services