Repository: cxf Updated Branches: refs/heads/3.0.x-fixes 0c3bd1aa0 -> cc08872e7
[CXF-5688] Ninor adjustments to the enum conversion code Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/cc08872e Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/cc08872e Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/cc08872e Branch: refs/heads/3.0.x-fixes Commit: cc08872e77410f6217db60947ebb0ba5363d219d Parents: 0c3bd1a Author: Sergey Beryozkin <[email protected]> Authored: Mon Oct 6 11:59:00 2014 +0100 Committer: Sergey Beryozkin <[email protected]> Committed: Mon Oct 6 12:01:19 2014 +0100 ---------------------------------------------------------------------- .../org/apache/cxf/jaxrs/utils/InjectionUtils.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/cc08872e/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 d59535f..cab2f3b 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 @@ -1296,10 +1296,21 @@ public final class InjectionUtils { } else if (cls.isPrimitive()) { return PrimitiveUtils.read(value, cls); } else if (cls.isEnum()) { - if (m == null || !MessageUtils.getContextualBoolean(m, ENUM_CONVERSION_CASE_SENSITIVE, false)) { - value = value.toUpperCase(); + if (m != null && !MessageUtils.getContextualBoolean(m, ENUM_CONVERSION_CASE_SENSITIVE, false)) { + obj = invokeValueOf(value.toUpperCase(), cls); } - return invokeValueOf(value, cls); + if (obj == null) { + try { + obj = invokeValueOf(value, cls); + } catch (RuntimeException ex) { + if (m == null) { + obj = invokeValueOf(value.toUpperCase(), cls); + } else { + throw ex; + } + } + } + return obj; } else { try { Constructor<?> c = cls.getConstructor(new Class<?>[]{String.class});
