dwr icon indicating copy to clipboard operation
dwr copied to clipboard

Bug fix for LocalUtil

Open moonfruit opened this issue 4 years ago • 3 comments

Previous LocalUtil.java makes below useless: clazz = Thread.currentThread().getContextClassLoader().loadClass(remappedClassName); Because of the next: clazz = LocalUtil.class.getClassLoader().loadClass(remappedClassName);

moonfruit avatar Apr 10 '21 03:04 moonfruit

What bug is being fixed with this change? It appears to be a stylistic change that doesn't impact the results.

dmarginian avatar Apr 11 '21 13:04 dmarginian

You can see this:

https://github.com/directwebremoting/dwr/blob/c1d9375e6a46954cd820de7a6d6418529f72277f/core/api/main/java/org/directwebremoting/util/LocalUtil.java#L1179-L1197

the code run this:

clazz = LocalUtil.class.getClassLoader().loadClass(remappedClassName);

immediately after this:

clazz = Thread.currentThread().getContextClassLoader().loadClass(remappedClassName);

So even clazz = Thread.currentThread().getContextClassLoader().loadClass(remappedClassName) is successful returned, the program will also run clazz = LocalUtil.class.getClassLoader().loadClass(remappedClassName), this makes clazz = Thread.currentThread().getContextClassLoader().loadClass(remappedClassName) useless. Or we can just run clazz = LocalUtil.class.getClassLoader().loadClass(remappedClassName) if this is you wanted, but I think not.

moonfruit avatar Apr 12 '21 02:04 moonfruit

Yes, thanks. I wonder if the first attempt is even needed. I would have to look into more but this change looks fine.

dmarginian avatar Apr 12 '21 14:04 dmarginian