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

ConcurrentModificationException #70

Open
lyx0224 opened this issue Jan 18, 2018 · 4 comments
Open

ConcurrentModificationException #70

lyx0224 opened this issue Jan 18, 2018 · 4 comments

Comments

@lyx0224
Copy link

lyx0224 commented Jan 18, 2018

遍历数组时候的exception
ConcurrentModificationException at java.util.ArrayList$ListIterator.next(ArrayList.java:at 573)
at com.rits.cloning.FastClonerArrayList.clone()

@kostaskougios
Copy link
Owner

I think this is due to some other thread modifying the cloned array list. Cloner doesn't synchronize access (wouldn't be a very good thing to do).

@bergmannm
Copy link

@lyx0224
Could be also due to bug in your code, for example, following code fails, because sublist doesn't allow structural modification to the backing list.

List<String> a = new LinkedList<String>();
a.add("1");
a.add("2");
a.add("3");
List<String> b = a.subList(0, 1);
b.add("3");
b.remove(0);
a.remove("3");
List<String> clone = cloner.deepClone(b); // JDK8 throws java.util.ConcurrentModificationException
clone.size(); // with JDK 10 clone gets created, but querying it's size fails with java.util.ConcurrentModificationException

@spullara
Copy link
Contributor

spullara commented Aug 7, 2019

I believe that this might be fixed. In later Java versions we needed to specially handle AbstractList$Sublist. Can you check with version 1.10.0?

@gfiorini
Copy link

gfiorini commented Nov 30, 2019

Yesterday I had the same Exception because I was cloning a Java Bean with a Logger property in it.
(I forgot the static keyword) but crashed all the JVM. I would expect that if it was only a concurrentException it should fail the deepClone method

(lib version 1.9.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants