On 01/02/2012 11:50, Ivan wrote: Here's what the reply should have looked like, without the top-posting.
> 2012/2/1 Christopher Schultz <ch...@christopherschultz.net> > > Ivan, > > On 1/27/12 11:40 PM, Ivan wrote: >>>> if (result != null) return result; >>>> >>>> // Checking thread biding result = >>>> threadBindings.get(currentThread); <-------------- Here, the value >>>> from threadBindings is always ignored ? is there something like "if >>>> (result != null) return result;" required there ? >>>> >>>> // Checking parent CL binding currentCL = currentCL.getParent(); >>>> while (currentCL != null) { result = clBindings.get(currentCL); if >>>> (result != null) return result; currentCL = currentCL.getParent(); >>>> } >>>> >>>> if (result == null) throw new IllegalStateException("Illegal class >>>> loader binding"); >>>> >>>> return result; > > That does look fishy. > > "result" will be ignored if currentCL.getParent returns non-null. If > currentCL.getParent returns null, then the method throws an exception. > It looks like this could be re-written in a more straightforward way > like this: > > currentCL = currentCL.getParent(); > if(null == result && null == currentCL) > throw new IllegalArgumentException(...); > > while(currentCL != null) > // continue > > Of course, you still need to check for null after the loop, so it's > not like the change really affects anything other than minor readability. No sure whether I understood you clearly, if a context is binding on the current thread, and current context classloader has parent classloader, current get method will throw an IllegalStateException. So my question is that, in this scenario, should the context binded on the thread be ignored ? I did not find too many comments on the svn log, while I guess that the logic may be : a. Check whether there is a context binding on the current context classloader, if does, return it. b. Check whether there is a context binding on the current thread, if does, return it. c. Check whether there is a context binding on the classloader tree of the current context classloader, if does return it. d. Throw an IllegalStateException. > > -chris >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >> For additional commands, e-mail: users-h...@tomcat.apache.org >> >> > > -- [key:62590808]
signature.asc
Description: OpenPGP digital signature