cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6682] Initializing UB later
Date Wed, 18 Nov 2015 16:07:48 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 2920c9bdb -> 577eb154c


[CXF-6682] Initializing UB later


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/577eb154
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/577eb154
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/577eb154

Branch: refs/heads/3.1.x-fixes
Commit: 577eb154c09a0654fc1d54d4743b369b84d3fd5a
Parents: 2920c9b
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Wed Nov 18 16:06:10 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed Nov 18 16:07:26 2015 +0000

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java  | 11 +++++++++--
 .../org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java   |  6 ++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/577eb154/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
index 2ceff49..389cc1c 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
@@ -37,7 +37,7 @@ import org.apache.cxf.jaxrs.utils.HttpUtils;
 
 public class LinkBuilderImpl implements Builder {
     private static final String DOUBLE_QUOTE = "\"";
-    private UriBuilder ub = new UriBuilderImpl();
+    private UriBuilder ub;
     private URI baseUri;
     private Map<String, String> params = new HashMap<String, String>(6);
     
@@ -55,9 +55,16 @@ public class LinkBuilderImpl implements Builder {
     }
 
     private URI getResolvedUri(Object... values) {
+        if (ub == null) {
+            ub = new UriBuilderImpl();
+            if (baseUri != null) {
+                ub.uri(baseUri);    
+            }
+            
+        }
         URI uri = ub.build(values);
                 
-        if (!uri.isAbsolute() && baseUri != null) {
+        if (!uri.isAbsolute() && baseUri != null && baseUri.isAbsolute())
{
             UriBuilder linkUriBuilder = UriBuilder.fromUri(baseUri);
             return HttpUtils.resolve(linkUriBuilder, uri);    
         } else {

http://git-wip-us.apache.org/repos/asf/cxf/blob/577eb154/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java
index 70920cc..3662eb5 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java
@@ -59,6 +59,12 @@ public class LinkBuilderImplTest extends Assert {
     }
     
     @Test
+    public void testSelfLink() throws Exception {
+        Link link = new LinkBuilderImpl().baseUri("http://localhost:8080/resource/1").rel("self").build();
+        assertEquals("<http://localhost:8080/resource/1>;rel=\"self\"", link.toString());
+    }
+    
+    @Test
     public void testBuildManyRels() throws Exception {
         Link.Builder linkBuilder = new LinkBuilderImpl();
         Link prevLink = linkBuilder.uri("http://example.com/page1").rel("1").rel("2").build();


Mime
View raw message