I created a @DateFormat annotation for unmarshalling query parameters into
Date objects. Initially, I thought it was working well, but once I started
using more than one date format, I ran into trouble.

The user guide states that a StringParameterUnmarshaller "is created per
injector," but its JavaDoc says, "Instances of this class are created per
parameter injection." I'm not sure what "created per injector" means, but I
read "created per parameter injection" to mean that my custom unmarshaller
should be instantiated per resource method call. This is consistent with
the example in the user guide, which assumes that setAnnotations() is
called for each request. Otherwise, only one date format could ever be
registered, and also, DateFormatter would not be thread-safe.

These are exactly the two issues I've run into: only one date format is
ever used to unmarshal query parameters, so many of my resource methods
fail because of wacky dates. Furthermore, when running at high load, date
parsing sometimes fails when multiple threads access the same
SimpleDateFormat instance. I've verified that the only
time setAnnotations() is called on my custom parameter unmarshaller is
during the very first request, as part of ResteasyDeployment.start().

Is this "caching" of StringParameterUnmarshallers by design?

"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
Resteasy-users mailing list

Reply via email to