cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject cxf git commit: [CXF-6820]:LinkBuilderImpl#link() doesn't throw exception for invalid input
Date Fri, 04 Mar 2016 09:49:58 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 42fa890e7 -> be5f1c3d4


[CXF-6820]:LinkBuilderImpl#link() doesn't throw exception for invalid input


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

Branch: refs/heads/master
Commit: be5f1c3d4e0a9eb2eb87fc4e3ec6373d6a9e3db4
Parents: 42fa890
Author: Jim Ma <ema@apache.org>
Authored: Fri Mar 4 17:49:37 2016 +0800
Committer: Jim Ma <ema@apache.org>
Committed: Fri Mar 4 17:49:37 2016 +0800

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java  |  2 +-
 .../org/apache/cxf/jaxrs/impl/LinkBuilderImplTest.java   | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/be5f1c3d/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 389cc1c..115d213 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
@@ -84,7 +84,7 @@ public class LinkBuilderImpl implements Builder {
         
         link = link.trim();
         if (link.length() > 1 && link.startsWith("<")) {
-            int index = link.indexOf(">", 1);
+            int index = link.lastIndexOf(">", link.length());
             if (index != -1) {
                 String uri = link.substring(1, index);
                 ub = UriBuilder.fromUri(uri);

http://git-wip-us.apache.org/repos/asf/cxf/blob/be5f1c3d/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 3662eb5..a487fd5 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
@@ -111,6 +111,17 @@ public class LinkBuilderImplTest extends Assert {
         assertTrue(resource.contains("<consumesappjson>"));
     }
     
+    @Test
+    public void testInvalidString() throws Exception {
+        try {
+            Link.Builder linkBuilder = Link.fromMethod(TestResource.class, "consumesAppJson");
+            linkBuilder.link("</cxf>>");
+            fail("IllegalArgumentException is expected");
+        } catch (java.lang.IllegalArgumentException e) {
+            // expected
+        }
+    }
+    
     @Path("resource")
     public static class TestResource {
         @POST


Mime
View raw message