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 on remove you #8

Closed
BiggA94 opened this issue May 23, 2017 · 6 comments
Closed

ConcurrentModificationException on remove you #8

BiggA94 opened this issue May 23, 2017 · 6 comments

Comments

@BiggA94
Copy link
Contributor

BiggA94 commented May 23, 2017

To reproduce:
The following generates a Concurrent Modification Exception:

@Test
public void testRemoveObj(){
   University uni = new University().withName("UniKasselVersitaet");
   Student student1 = uni.createStudents().withName("Peter");
   Student student2 = uni.createStudents().withName("Paul");
   Student student3 = uni.createStudents().withName("Mary");

   IdMap idMap = UniversityCreator.createIdMap("u");
   idMap.toJsonArray(uni);
   uni.removeYou();
}

One solution for this problem is to remove

Collection<?> continee = (Collection<?>) reference;
Iterator<?> i = continee.iterator();
while (i.hasNext()) {
   creator.setValue(oldValue, prop, i.next(),
   SendableEntityCreator.REMOVE);
}

and replace it with

Object[] array = ((Collection) reference).toArray();
for (int i = 0; i < array.length; i++) {
   Object object = array[i];
   creator.setValue(oldValue, prop, object,
   SendableEntityCreator.REMOVE);
}

(IdMap, line 422ff)
This works for newly generated Models but not for the one, that is inside the test-package.
And it is also slower.

@ghost
Copy link

ghost commented May 23, 2017

Your issue doesn't follow our guidelines. Please fix the following:

  • Issue must have at least one label (?)

Click here for details.

Thank you! 🙏

This comment was made by GitMagic – Magically enforcing your contribution guidelines.

@ghost
Copy link

ghost commented May 23, 2017

This issue still violates some of our guidelines:

  • Issue description must include reproduction steps (?)

Click here for details.

2 similar comments
@ghost
Copy link

ghost commented May 23, 2017

This issue still violates some of our guidelines:

  • Issue description must include reproduction steps (?)

Click here for details.

@ghost
Copy link

ghost commented May 23, 2017

This issue still violates some of our guidelines:

  • Issue description must include reproduction steps (?)

Click here for details.

@ghost
Copy link

ghost commented May 23, 2017

Thank you, everything looks good now! :bowtie:

StefanLindel added a commit that referenced this issue May 24, 2017
@StefanLindel
Copy link
Contributor

Use a SimpleIterator for moving over a Collection

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

No branches or pull requests

2 participants