Robert Burrell Donkin ha scritto: > On 8/9/07, Stefano Bagnara <[EMAIL PROTECTED]> wrote: >> Bernd Fondermann ha scritto: >>> What types of exceptions do you get? NPE? >>> >>> if it wasn't for a ThreadLocal, I'd say that this method's init is not >>> atomic, if fieldInstance is NULL: >>> >>> static protected void setInstance(CommandStateManager conditionManager) >>> { >>> if (null == fieldInstance) >>> fieldInstance = new ThreadLocal(); >>> fieldInstance.set(conditionManager); >>> } >>> >>> It leaves ThreadLocal uninitialized but accessible for a little >>> moment. if the method got interrupted in between and getInstance() >>> gets executed, this might result in a NPE. >> Good catch!! > > +1 > > not sure that it's possible to create a good test for this but > https://issues.apache.org/jira/browse/JSIEVE-10 demonstrates that it > occurs in the wild. unless someone jumps in with a good idea for a > test, i'll commit a fix without a test. > > - robert
Go ahead: I don't think a test can be written for similar racing conditions as there is no way to control 2 threads in order to have them executing that code with the specific timing needed to show the problem. Stefano --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]