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:06:29 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 886f14caf -> ce969249d


[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/ce969249
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ce969249
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ce969249

Branch: refs/heads/master
Commit: ce969249da7101a53d5c48fc6e12bde455d4a6dd
Parents: 886f14c
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:06:10 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/ce969249/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/ce969249/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