jai-imageio / jai-imageio-jpeg2000

JPEG2000 support for Java Advanced Imaging Image I/O Tools API
Other
73 stars 56 forks source link

Cannot unregister FacilityManager callbacks #3

Closed d09 closed 9 years ago

d09 commented 9 years ago

jj2000.j2k.util.FacilityManager has a couple of static hashtables used for callbacks. You can add entries to these hashtables but not remove them, this will cause a memory leak eventually.

Here is a proposed patch that fixes the problem:

--- src/main/java/jj2000/j2k/util/FacilityManager.java~ 2015-03-16 13:56:55.000000000 +0000 +++ src/main/java/jj2000/j2k/util/FacilityManager.java 2015-04-01 10:50:03.000000000 +0100 @@ -101,6 +101,14 @@ } }

stain commented 9 years ago

Thanks, I've incorporated this and modified unregisterMsgLogger to reset to the default System.out logger as I don't think callers handle null-loggers. (Really these should be changed for java.util.logging I guess)

A ThreadLocal might have been better choice here - but as the current register methods takes the Thread as an argument that would break the old API (you can't set another thread's ThreadLocal).

stain commented 9 years ago

If you could test it for me, (or add a test case? Perhaps tricky..) then I can release this as a new patch version to Maven Central.