Importer and monitoring REST resources are not thread-safe

Description

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.

Environment

None

Assignee

Andrea Aime

Reporter

codehaus

Triage

None

Fix versions

Affects versions

Components

Priority

High
Configure