cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r800498 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Date Mon, 03 Aug 2009 19:13:27 GMT
Author: dkulp
Date: Mon Aug  3 19:13:27 2009
New Revision: 800498

URL: http://svn.apache.org/viewvc?rev=800498&view=rev
Log:
[CXF-2374] Handle possible number format exception when reading primitive param.

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=800498&r1=800497&r2=800498&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Mon Aug  3 19:13:27 2009
@@ -263,7 +263,18 @@
         }
         
         if (pClass.isPrimitive()) {
-            return PrimitiveUtils.read(value, pClass);
+            try {
+                return PrimitiveUtils.read(value, pClass);
+            } catch (NumberFormatException nfe) {
+                //
+                //  For a path parameter this is probably a 404,
+                //  for others a 400...
+                //
+                if (pType == ParameterType.PATH) {
+                    throw new WebApplicationException(nfe, Response.Status.NOT_FOUND);
+                }
+                throw new WebApplicationException(nfe, Response.Status.BAD_REQUEST);
+            }
         }
         // check constructors accepting a single String value
         try {



Mime
View raw message