Closed rbanikaz closed 12 years ago
Very cool, you are correct, this slip through the crack. We will put this fix in 1.9.9.
Note: In the Snow implementation, we will not use Enum.valueOf as it throws exception when no match, but the default Snow WebParamResolver in these type of circumstance is to return null.
In xadcms we use the following utility function to return null in that case:
public static <T extends Enum<T>> T enumValueOf(Class<T> enumClass, String name) {
try {
return Enum.valueOf(enumClass, name);
} catch(Exception e) {
return null;
}
}
ObjectUtil.getValue(value,EnumClass) does the same. But good to have your own.
Fix in the main trunk. Will be available in 1.9.9.
@rbanikaz note that your fix will still run, since it will override the default system parser.
We ran into a problem where snow 1.9.x will go into an infinite loop when we have a Enum type in the WebHandler method. This was working in the old snow.
The infinite loop occurs in WebParamResolverRegistry.getWebParamResolverRef:
Enum types do not extend from Object.class so this was being repeated and system would hang.
Resolved the issue by creating a WebParamResolver for java.lang.Enum: