Repository: cxf Updated Branches: refs/heads/master 190b89b86 -> 55fe54262
[CXF-5722] Delaying the exception propagation only if it is enum and fromValue method Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/55fe5426 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/55fe5426 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/55fe5426 Branch: refs/heads/master Commit: 55fe5426234f9040c41f35bb38110f1dc35eb21b Parents: 190b89b Author: Sergey Beryozkin <[email protected]> Authored: Thu May 1 11:44:44 2014 +0100 Committer: Sergey Beryozkin <[email protected]> Committed: Thu May 1 11:44:44 2014 +0100 ---------------------------------------------------------------------- .../java/org/apache/cxf/jaxrs/utils/InjectionUtils.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/55fe5426/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 0a7b11b..e6c86a8 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 @@ -468,14 +468,19 @@ public final class InjectionUtils { try { result = evaluateFactoryMethod(value, cls, pType, mName); if (result != null) { + factoryMethodEx = null; break; } } catch (Exception ex) { - // Don't throw exception immediately, but store it and try other factory methods + // If it is enum and the method name is "fromValue" then don't throw + // the exception immediately but try the next factory method factoryMethodEx = ex; + if (!cls.isEnum() || !"fromValue".equals(mName)) { + break; + } } } - if ((factoryMethodEx != null) && (result == null)) { + if (factoryMethodEx != null) { Throwable t = getOrThrowActualException(factoryMethodEx); LOG.severe(new org.apache.cxf.common.i18n.Message("CLASS_VALUE_OF_FAILURE", BUNDLE, @@ -500,8 +505,6 @@ public final class InjectionUtils { // no luck: try another factory methods } catch (IllegalAccessException ex) { // factory method is not accessible: try another - } catch (IllegalArgumentException ex) { - // String argument doesn't fit to factory method: try another } return null;
