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-6664] Fixing NPE based on the input from with the help from Michael Krenn
Date Thu, 05 Nov 2015 17:16:19 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 1c092b9b3 -> 6d7d8eb39


[CXF-6664] Fixing NPE based on the input from with the help from Michael Krenn


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

Branch: refs/heads/master
Commit: 6d7d8eb39c6fdd1323bf50b410302e48240d0a3a
Parents: 1c092b9
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Nov 5 17:14:05 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Nov 5 17:16:01 2015 +0000

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/impl/LinkBuilderImpl.java   | 19 ++++++++++++++++---
 .../cxf/jaxrs/impl/LinkBuilderImplTest.java      |  2 +-
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6d7d8eb3/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 5fda9d1..d35a2ed 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
@@ -74,12 +74,25 @@ public class LinkBuilderImpl implements Builder {
 
     @Override
     public Builder link(String link) {
+        
+        link = link.trim();
+        if (link.length() > 1 && link.startsWith("<")) {
+            int index = link.indexOf(">", 1);
+            if (index != -1) {
+                String uri = link.substring(1, index);
+                ub = UriBuilder.fromUri(uri);
+                if (index + 1 == link.length()) {
+                    link = "";
+                } else {
+                    link = link.substring(index + 1);
+                }
+            }
+        }
+        
         String[] tokens = StringUtils.split(link, ";");
         for (String token : tokens) {
             String theToken = token.trim();
-            if (theToken.startsWith("<") && theToken.endsWith(">")) {
-                ub = UriBuilder.fromUri(theToken.substring(1, theToken.length() - 1));
-            } else {
+            if (!theToken.isEmpty()) {
                 int i = theToken.indexOf('=');
                 if (i != -1) {
                     String name = theToken.substring(0, i);

http://git-wip-us.apache.org/repos/asf/cxf/blob/6d7d8eb3/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 a3790dc..70920cc 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
@@ -41,7 +41,7 @@ public class LinkBuilderImplTest extends Assert {
     }
     
     @Test
-    public void testbBuildObjects() throws Exception {
+    public void testBuildObjects() throws Exception {
         StringBuilder path1 = new StringBuilder().append("p1");
         ByteArrayInputStream path2 = new ByteArrayInputStream("p2".getBytes()) {
             @Override


Mime
View raw message