Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support for JDK 1.8 #63

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Fix problem when enum value is null
Correctly sets the member of type enum to null if needed. Avoiding an
exception because Enum.name() is null.
  • Loading branch information
agrison committed Sep 18, 2014
commit 2507a956e4369b1a077fb8197dc095901bc3926b
2 changes: 1 addition & 1 deletion src/main/java/redis/clients/johm/JOhmUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public static Object convert(final Class<?> type, final String value) {
}

if (type.isEnum() || type.equals(Enum.class)) {
return Enum.valueOf((Class<Enum>)type, value);
return value == null ? null : Enum.valueOf((Class<Enum>)type, value);
}

// Raw Collections are unsupported
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/redis/clients/johm/ConvertorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ public void testEnumConvertors() {

converted = JOhmUtils.Convertor.convert(FooEnum.class, "FOO");
assertNotSame(FooEnum.BAZZ, converted);

converted = JOhmUtils.Convertor.convert(FooEnum.class, null);
assertEquals(null, converted);
}

@Test
Expand Down