-
-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NPE in ICC_Profile.getInstance() #631
Comments
Thanks Timofey, I'm aware of the JDK bug as it has troubled me and users of the library for years. I was hoping for the JDK fix to be backported to at least JDK 11, but I guess we weren't that lucky... Anyway, I think your workaround is interesting, as it explicitly (well, as close as it gets) invokes I believe even Now, most of the ICC profile handling in the library is already consolidated in the I've been thinking about this problem for a while, and I think we could do slightly better, using a hack that exploits the SPI mechanism to activate profiles before any attempt at using ImageIO plugins. It's still not 100% bullet proof, as applications could still use ICC profiles before ImageIO SPIs are loaded, or our plugins could be loaded "lazily" (ie. I still think the only 100% sure way is to include your own startup code, that forces profile activation. Let me know what you think, or if you have ideas on how we can make sure the code is actually run "early enough", make sure to share them! 😀 -- |
Searching for I think moving all As for moving the initialization to SPI, I don't think it's worth doing it right now. Also, it would be a good idea to mention this workaround somewhere in README / documentation (or maybe in exception message text 😎) -- that'll help people, who hit this error again for any reason, to correctly report it or add the workaround in their startup code. |
Yes, it should also initialize the class -- even better approach than creating a new instance. |
Excellent! You are halfway to making the pull request already! 😀 Best regards, -- |
Probably it will be good to prepare the reasoning why these bugs are causing so much troubles for so many users and it would be nice to back port the corresponding fixes from JDK17 to JDK 11? |
@mrserb I completely agree. But I don't think this is specific to Corretto, so I guess it should be filed at OpenJDK https://bugs.openjdk.java.net/. PS: Anyone can do this, it doesn't have to be me. 😀 |
… of ICC_Profile.getInstance() (cherry picked from commit b2c5915)
New and improved version of profile activation workaround will be out in 3.8.0. Still, it will not fix the underlying problem, and upgrading to JDK 17 or other version that has the JDK 17 fix backported is highly recommended. |
On JDK11, we've started to use TwelveMonkeys recently and hit the following reproducible NPE in out tests:
The root cause (basically) is thread-unsafe ProfileDeferralMgr:
https://bugs.openjdk.java.net/browse/JDK-8058973
The bug was fixed in JDK 17+:
openjdk/jdk@64a150c5
Since this fix is unlikely to be backported to earlier JDKs, the ask here is to implement the workaround in TwelveMonkeys.
The proposal is to add this static initializer to all classes where
ICC_Profile.getInstance()
is called:It might be a good idea to consolidate
ICC_Profile.getInstance()
calls to minimize the number of the affected classes.The text was updated successfully, but these errors were encountered: