cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r966026 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
Date Tue, 20 Jul 2010 21:45:20 GMT
Author: sergeyb
Date: Tue Jul 20 21:45:19 2010
New Revision: 966026

URL: http://svn.apache.org/viewvc?rev=966026&view=rev
Log:
[CXF-2887] Fixing NPE in UriBuilderImpl

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java?rev=966026&r1=966025&r2=966026&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
Tue Jul 20 21:45:19 2010
@@ -162,8 +162,14 @@ public class UriBuilderImpl extends UriB
         // is promising unfortunatley it causes the loss of encoded reserved values such
as +,
         // which might cause problems if consumers do rely on URLEncoder which would turn
'+' into
         // ' ' or would break the contract in when query parameters are expected to have
%2B 
-        
+        if (values == null) {
+            throw new IllegalArgumentException("Template parameter values are set to null");
+        }
         for (int i = 0; i < values.length; i++) {
+            if (values[i] == null) {
+                throw new IllegalArgumentException("Template parameter value is set to null");
+            }
+            
             values[i] = HttpUtils.encodePartiallyEncoded(values[i].toString(), false);
         }
         return doBuild(true, values);

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java?rev=966026&r1=966025&r2=966026&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
Tue Jul 20 21:45:19 2010
@@ -126,6 +126,18 @@ public class UriBuilderImplTest extends 
         assertEquals("URI is not built correctly", "http://bar/", newUri.toString());
     }
     
+    @Test(expected = IllegalArgumentException.class)
+    public void testNullPathWithBuildEncoded() throws Exception {
+        URI uri = new URI("http://bar");
+        new UriBuilderImpl(uri).path("{bar}").buildFromEncoded((Object[])null);
+    }
+    
+    @Test(expected = IllegalArgumentException.class)
+    public void testNullPathWithBuildEncoded2() throws Exception {
+        URI uri = new URI("http://bar");
+        new UriBuilderImpl(uri).path("{bar}").buildFromEncoded(new Object[] {null});
+    }
+    
     @Test
     public void testPathTrailingSlash2() throws Exception {
         URI uri = new URI("http://bar");



Mime
View raw message