question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ConcurrentModificationException on read

See original GitHub issue

Reading an image in concurrent environment fails. I’m reading images in a threadpool with size up to 8 threads. The issue was observed on build from latest sources on master branch.

This particular error happened when reading a thumbnail, which I do when the size is greater than requested size, but I think it appears when reading the image itself as well.

java.util.ConcurrentModificationException: null
	at java.base/java.util.Vector$Itr.checkForComodification(Vector.java:1295) ~[na:na]
	at java.base/java.util.Vector$Itr.next(Vector.java:1251) ~[na:na]
	at java.desktop/sun.java2d.cmm.ProfileDeferralMgr.activateProfiles(ProfileDeferralMgr.java:93) ~[na:na]
	at java.desktop/java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:788) ~[na:na]
	at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.setImageData(JPEGImageReader.java:771) ~[na:na]
	at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native Method) ~[na:na]
	at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.readNativeHeader(JPEGImageReader.java:723) ~[na:na]
	at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(JPEGImageReader.java:347) ~[na:na]
	at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(JPEGImageReader.java:493) ~[na:na]
	at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.readHeader(JPEGImageReader.java:716) ~[na:na]
	at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1173) ~[na:na]
	at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1153) ~[na:na]
	at java.desktop/javax.imageio.ImageReader.read(ImageReader.java:938) ~[na:na]
	at com.twelvemonkeys.imageio.plugins.jpeg.ThumbnailReader.readJPEGThumbnail(ThumbnailReader.java:72) ~[imageio-jpeg-3.3.9.jar:3.3.9]
	at com.twelvemonkeys.imageio.plugins.jpeg.EXIFThumbnailReader.readJPEG(EXIFThumbnailReader.java:138) ~[imageio-jpeg-3.3.9.jar:3.3.9]
	at com.twelvemonkeys.imageio.plugins.jpeg.EXIFThumbnailReader.readJPEGCached(EXIFThumbnailReader.java:103) ~[imageio-jpeg-3.3.9.jar:3.3.9]
	at com.twelvemonkeys.imageio.plugins.jpeg.EXIFThumbnailReader.getWidth(EXIFThumbnailReader.java:221) ~[imageio-jpeg-3.3.9.jar:3.3.9]
	at com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader.getThumbnailWidth(JPEGImageReader.java:1095) ~[imageio-jpeg-3.3.9.jar:3.3.9]````

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
sghpjuikitcommented, Mar 26, 2018

I’m back. After period of use, I have seen no ConcurrentModificationException. It’s not 100%, but I consider the issue resolved and the solution satisfactory. I’m posting the entirety of the code that I’ve been using.

        // Load deferred color space profiles to avoid ConcurrentModificationException due to JDK
        // Use in public static main void or prior to application initialization
        // https://github.com/haraldk/TwelveMonkeys/issues/402
        // https://bugs.openjdk.java.net/browse/JDK-6986863
        // https://stackoverflow.com/questions/26297491/imageio-thread-safety
        ICC_Profile.getInstance(ColorSpace.CS_sRGB).getData();
        ICC_Profile.getInstance(ColorSpace.CS_PYCC).getData();
        ICC_Profile.getInstance(ColorSpace.CS_GRAY).getData();
        ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ).getData();
        ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB).getData();

Thx for the help.

3reactions
sghpjuikitcommented, Jan 24, 2018

Just an update, I still was not able to reproduce the issue, hence your workaround may have worked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.util.ConcurrentModificationException when read from ...
The issue is not with the logging framework but with line shared.putAll(props);. Properties class extends Hashtable and it is possible for ...
Read more >
How to Avoid the Concurrent Modification Exception in Java
The ConcurrentModificationException in Java occurs when an object is attempted to be modified concurrently without permission.
Read more >
ConcurrentModificationException in Java - Javatpoint
The ConcurrentModificationException occurs when an object is tried to be modified concurrently when it is not permissible. This exception usually comes when ...
Read more >
java.util.ConcurrentModificationException - DigitalOcean
java.util.ConcurrentModificationException is a very common exception when working with Java collection classes. Java Collection classes are fail ...
Read more >
How to Avoid/Fix ConcurrentModificationException ... - Java67
Solution: Use Iterator if you are doing it on the single-threaded environment, otherwise use concurrent collection classes like CopyOnWriteArrayList to remove ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found