Mercurial Hosting > luan
changeset 1613:92beba8bf1c8
handle ConcurrentModificationException
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 24 May 2021 22:30:17 -0600 |
parents | 8852f34a646a |
children | 557bb90b70d7 |
files | src/luan/LuanTable.java |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
diff -r 8852f34a646a -r 92beba8bf1c8 src/luan/LuanTable.java --- a/src/luan/LuanTable.java Sun May 23 15:17:25 2021 -0600 +++ b/src/luan/LuanTable.java Mon May 24 22:30:17 2021 -0600 @@ -11,6 +11,7 @@ import java.util.Comparator; import java.util.Set; import java.util.HashSet; +import java.util.ConcurrentModificationException; public final class LuanTable implements LuanMutable { @@ -351,11 +352,15 @@ return new LuanFunction() { final Iterator<Map.Entry> iter = rawIterator(); - @Override public Object[] call(Luan luan,Object[] args) { + @Override public Object[] call(Luan luan,Object[] args) throws LuanException { if( !iter.hasNext() ) return LuanFunction.NOTHING; - Map.Entry<Object,Object> entry = iter.next(); - return new Object[]{entry.getKey(),entry.getValue()}; + try { + Map.Entry<Object,Object> entry = iter.next(); + return new Object[]{entry.getKey(),entry.getValue()}; + } catch(ConcurrentModificationException e) { + throw new LuanException("table modified while iterating"); + } } }; }