You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (Jira)" <ji...@apache.org> on 2022/10/21 07:44:00 UTC

[jira] [Closed] (WW-3599) Struts2 ignores 'final' modifier when backing form onto field

     [ https://issues.apache.org/jira/browse/WW-3599?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart closed WW-3599.
-----------------------------
    Resolution: Resolved

This was resolved in OGNL at some point

> 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 was sent by Atlassian Jira
(v8.20.10#820010)