Skip to content
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

Concurrent Modification Exception #557

Closed
cbdmaul opened this issue Sep 13, 2016 · 8 comments
Closed

Concurrent Modification Exception #557

cbdmaul opened this issue Sep 13, 2016 · 8 comments

Comments

@cbdmaul
Copy link
Collaborator

cbdmaul commented Sep 13, 2016

Exception in thread "oCam-5CRO-U 1" java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429)
at java.util.HashMap$KeyIterator.next(HashMap.java:1453)
at com.shootoff.camera.shotdetection.JavaShotDetector.processFrame(JavaShotDetector.java:292)
at com.shootoff.camera.CameraManager.processFrame(CameraManager.java:626)
at com.shootoff.camera.CameraManager.handleFrame(CameraManager.java:515)
at com.shootoff.camera.CameraManager.newFrame(CameraManager.java:498)
at com.shootoff.camera.cameratypes.SarxosCaptureCamera.run(SarxosCaptureCamera.java:186)
at java.lang.Thread.run(Thread.java:745)

@phrack phrack added the bug label Sep 14, 2016
@phrack phrack added this to the 3.9 GUI Improvement milestone Sep 14, 2016
@phrack
Copy link
Owner

phrack commented Sep 16, 2016

Why is this a HashMap error when 292 is reading a Set not a Map?

@cbdmaul
Copy link
Collaborator Author

cbdmaul commented Sep 16, 2016

That's a very good question. I thought that I might have had an indeterminate state, leading to a mistaken exception, but that line has been Set not Map for as long as I went back...

@phrack
Copy link
Owner

phrack commented Sep 16, 2016

Also,

  1. It's coming from the oCam thread. Shouldn't JavaShotDetection be off if oCam is being used?
  2. This is very battle hardened code, hasn't been changed in several versions and this never came up before.

I am inclined to close this and maybe open an issue about 1 if you think it's a bug.

@cbdmaul
Copy link
Collaborator Author

cbdmaul commented Sep 16, 2016

The oCam is a regular camera, it uses JavaShotDetector

@phrack
Copy link
Owner

phrack commented Sep 16, 2016

In that case, we should give the thread a better name if we control it.

@cbdmaul
Copy link
Collaborator Author

cbdmaul commented Sep 16, 2016

I changed the thread name to the camera name because if I had two cameras and one of the threads hung or crashed, I didn't know which camera it was. We could add the detection method to the thread name as well.

@phrack
Copy link
Owner

phrack commented Sep 16, 2016

I'll do that in a second. I made a few other tweaks.

@phrack
Copy link
Owner

phrack commented Sep 16, 2016

PS. The problem is explained here: https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedSet(java.util.Set). We just have to synchronize on the for loop. This should solve the problem given the way synchronizedSet wraps a normal set. I have a few other messaging tweaks, but nothing that's a big deal.

@phrack phrack closed this as completed in 5d78d2d Sep 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants