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-6155] Reacting to ParamConverter IllegalArgumentException
Date Mon, 15 Dec 2014 12:34:12 GMT
Repository: cxf
Updated Branches:
  refs/heads/master e47e39411 -> 51c5ff8ad


[CXF-6155] Reacting to ParamConverter IllegalArgumentException


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

Branch: refs/heads/master
Commit: 51c5ff8ad31404ee566bf2c3f68897290a086405
Parents: e47e394
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Dec 15 12:33:53 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Dec 15 12:33:53 2014 +0000

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/utils/InjectionUtils.java  | 29 ++++++++++++--------
 1 file changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/51c5ff8a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
index cab2f3b..631d2e4 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
@@ -354,11 +354,15 @@ public final class InjectionUtils {
         
         value = decodeValue(value, decoded, pType);
         
-        Object result = createFromParameterHandler(value, pClass, genericType, paramAnns,
message);
+        Object result = null;
+        try {
+            result = createFromParameterHandler(value, pClass, genericType, paramAnns, message);
+        } catch (IllegalArgumentException nfe) {
+            throw createParamConversionException(pType, nfe);
+        }
         if (result != null) {
             return pClass.cast(result);
         }
-        
         if (pClass.isPrimitive()) {
             try {
                 @SuppressWarnings("unchecked")
@@ -368,15 +372,7 @@ public final class InjectionUtils {
                 // the object is a Boolean object
                 return ret;
             } catch (NumberFormatException nfe) {
-                //
-                //  For path, query & matrix parameters this is 404,
-                //  for others 400...
-                //
-                if (pType == ParameterType.PATH || pType == ParameterType.QUERY
-                    || pType == ParameterType.MATRIX) {
-                    throw ExceptionUtils.toNotFoundException(nfe, null);
-                }
-                throw ExceptionUtils.toBadRequestException(nfe, null);
+                throw createParamConversionException(pType, nfe);
             }
         }
         
@@ -431,6 +427,17 @@ public final class InjectionUtils {
         return pClass.cast(result);
     }
 
+    private static RuntimeException createParamConversionException(ParameterType pType, Exception
ex) {
+        //
+        //  For path, query & matrix parameters this is 404,
+        //  for others 400...
+        //
+        if (pType == ParameterType.PATH || pType == ParameterType.QUERY
+            || pType == ParameterType.MATRIX) {
+            return ExceptionUtils.toNotFoundException(ex, null);
+        }
+        return ExceptionUtils.toBadRequestException(ex, null);
+    }
     public static <T> T createFromParameterHandler(String value, 
                                                     Class<T> pClass,
                                                     Type genericType,


Mime
View raw message