Struts2 ignores 'final' modifier when backing form onto field
-------------------------------------------------------------

                 Key: WW-3599
                 URL: https://issues.apache.org/jira/browse/WW-3599
             Project: Struts 2
          Issue Type: Bug
          Components: Core Actions
    Affects Versions: 2.1.6
            Reporter: Jon
            Priority: Minor


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) {
      this.code = 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.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to