[Geoserver-devel] [jira] Created: (GEOS-4179) REST resources are not thread-safe, but shared by concurrent thread because of Spring

REST resources are not thread-safe, but shared by concurrent thread because of Spring
-------------------------------------------------------------------------------------

                 Key: GEOS-4179
                 URL: http://jira.codehaus.org/browse/GEOS-4179
             Project: GeoServer
          Issue Type: Bug
          Components: REST
    Affects Versions: 2.0.x, 2.1.x
            Reporter: Martins Linde
            Assignee: Andrea Aime
            Priority: Critical

Restlet resources are not designed to be thread-safe (response, request are stored in fields... ), but BeanResourceFinder method findTarget:

public Resource findTarget(Request request, Response response){
       Resource res = (Resource) applicationContext.getBean(getBeanToFind());
       res.init(getContext(), request, response);
       return res;
}

returns the same Resource instance to concurrent threads (Spring returns the same instance),
workaround is to tell Spring to give different instances, that can be done with scope="prototype" like:

<bean id="xResource" class="x.xResource" scope="prototype"/>

But it would be nice if it could be fixed in code not in the Spring configuration file, because users may forget to add scope attribute, which may lead to real time errors.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira