Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Resolved
-
2.1.6
-
None
-
None
Description
I had a bean and nested enum defined like
public class SomeBean {
private Type type;
// getters+setters for type
public static enum Type {
UNSET(0),
USER(1),
GROUP(2);
public final short code;
private Type(short code)
}
}
We accidentally included the final field 'code' as the name of a field on a form that was backed by Struts. e.g. something like:
<s:select name="someBeanInstance.type.code" ... />
When this field was submitted, the final field 'code' was updated on the enum to match the value picked in the select box. This caused a huge amount of confusion for a time, as this field is marked final and so shouldn't ever be updated... presumably Struts is using reflection to bypass the JVM enforcement on finality?
Fix would be to check a public field isn't marked final, before backing a form onto it.