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

Jon Pulice updated WW-5387:
---------------------------
    Description: 
When implementing {{ApplicationAware}} in an action, and calling 
{{remove(key)}} on the injected Map, the removed object reappears on subsequent 
actions, and the object is not removed from the ServletContext (implementing a 
ServletContextAttributeListener will show that only "added" and "replaced" 
events are triggered, but not "removed" events)

 

 
{code:java}
public class TestAction extends ActionSupport implements ApplicationAware {    
    public static final String APPLICATION_MAP_TEST_KEY = 
"com.testing.application.key";
    private Map<String, Object> applicationMap;    
    
    @Override
    public void withApplication(Map<String, Object> applicationMap) {
        this.applicationMap = applicationMap;
    }

    protected void testPutToApplicationMap() {
        applicationMap.put(APPLICATION_MAP_TEST_KEY, "Test application map 
value"); //This works fine
    }    
    
    protected Object testRemoveFromApplicationMap() {
        return applicationMap.remove(APPLICATION_MAP_TEST_KEY); //Does not work
    }

    ...
} {code}
 

 

The issue appears to be the change to the remove method signature in 
https://issues.apache.org/jira/browse/WW-5196 so that it no longer implements 
the Map interface (which specifies an argument of Object, not String)

  was:
When implementing {{ApplicationAware}} in an action, and calling 
{{remove(key)}} on the injected Map, the removed object reappears on subsequent 
actions, and the object is not removed from the ServletContext (implementing a 
ServletContextAttributeListener will show that only "added" and "replaced" 
events are triggered, but not "removed" events)

 

 
{code:java}
public class TestAction extends ActionSupport implements ApplicationAware {    
    public static final String APPLICATION_MAP_TEST_KEY = 
"com.testing.application.key";
    private Map<String, Object> applicationMap;    
    
    @Override
    public void withApplication(Map<String, Object> applicationMap) {
        this.applicationMap = applicationMap;
    }

    protected void testPutToApplicationMap() {
        applicationMap.put(APPLICATION_MAP_TEST_KEY, "Test application map 
value");
    }    
    
    protected Object testRemoveFromApplicationMap() {
        return applicationMap.remove(APPLICATION_MAP_TEST_KEY);
    }

    ...
} {code}
 

 

The issue appears to be the change to the remove method signature in 
https://issues.apache.org/jira/browse/WW-5196 so that it no longer implements 
the Map interface (which specifies an argument of Object, not String)


> ApplicationMap.remove does not remove the entry from the ServletContext
> -----------------------------------------------------------------------
>
>                 Key: WW-5387
>                 URL: https://issues.apache.org/jira/browse/WW-5387
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 6.2.0, 6.3.0
>            Reporter: Jon Pulice
>            Priority: Minor
>
> When implementing {{ApplicationAware}} in an action, and calling 
> {{remove(key)}} on the injected Map, the removed object reappears on 
> subsequent actions, and the object is not removed from the ServletContext 
> (implementing a ServletContextAttributeListener will show that only "added" 
> and "replaced" events are triggered, but not "removed" events)
>  
>  
> {code:java}
> public class TestAction extends ActionSupport implements ApplicationAware {   
>  
>     public static final String APPLICATION_MAP_TEST_KEY = 
> "com.testing.application.key";
>     private Map<String, Object> applicationMap;    
>     
>     @Override
>     public void withApplication(Map<String, Object> applicationMap) {
>         this.applicationMap = applicationMap;
>     }
>     protected void testPutToApplicationMap() {
>         applicationMap.put(APPLICATION_MAP_TEST_KEY, "Test application map 
> value"); //This works fine
>     }    
>     
>     protected Object testRemoveFromApplicationMap() {
>         return applicationMap.remove(APPLICATION_MAP_TEST_KEY); //Does not 
> work
>     }
>     ...
> } {code}
>  
>  
> The issue appears to be the change to the remove method signature in 
> https://issues.apache.org/jira/browse/WW-5196 so that it no longer implements 
> the Map interface (which specifies an argument of Object, not String)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to