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, while spawning zombie #584

Closed
Microsamp opened this Issue Oct 31, 2017 · 2 comments

Comments

Projects
2 participants
@Microsamp
Contributor

Microsamp commented Oct 31, 2017

2017/10/31 17:01:57 [SCHWERWIEGEND] Error occurred while pulsing world world
java.util.ConcurrentModificationException
at java.util.ArrayList.forEach(Unknown Source)
at net.glowstone.entity.ai.TaskManager.pulse(TaskManager.java:66)
at net.glowstone.entity.GlowEntity.pulse(GlowEntity.java:470)
at net.glowstone.entity.GlowLivingEntity.pulse(GlowLivingEntity.java:184)
at net.glowstone.entity.monster.GlowMonster.pulse(GlowMonster.java:54)
at net.glowstone.GlowWorld.pulse(GlowWorld.java:395)
at net.glowstone.scheduler.WorldScheduler$WorldThread.run(WorldScheduler.java:139)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Glowstone build(compiled locally): 2017.10.0-SNAPSHOT.6ecd65a (MC: 1.12.2)
Glowstone build(official): 2017.10.0-SNAPSHOT.18a3b49

Steps to reproduce:

  1. Spawn a zombie with a spawnegg
  2. Hit the zombie(so i tried to force him to move)
  3. Wait for movements
    (4. Sometimes i timed out, after placing 2 zombies)

EDIT: Would someone please edit the title to "ConcurrentModificationException caused by zombie movements" or something similiar?

@momothereal

This comment has been minimized.

Member

momothereal commented Oct 31, 2017

This is because the ArrayList in the task manager isn't concurrent, I'm not sure if fixing this would be much harder than changing the list to a Concurrent Set.

@Microsamp

This comment has been minimized.

Contributor

Microsamp commented Oct 31, 2017

Normal concurrent lists/sets don't support concurrent iterating in most cases.

So here we have to implement own synchronisation(e.g. synchronized-blocks or ReadWriteLock).

Alternative way(using Collections.synchronizedList()); Use .iterator() and call hasNext() and next() in a while loop

@momothereal momothereal added this to Ready for Development in 2017Q4 Nov 1, 2017

Microsamp pushed a commit to Microsamp/Glowstone that referenced this issue Nov 1, 2017

Microsamp added a commit to Microsamp/Glowstone that referenced this issue Nov 1, 2017

@wafflebot wafflebot bot removed the help wanted label Nov 23, 2017

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