Hi,
Lately, I have been getting some ConcurrentModificationExceptions while
testing my code. I searched for possible causes but I only find (the usual
and normal) cases where some kind of inappropriate modification is
performed to the data set while iterating.
My app is currently single threaded. In this particular piece of code,
where Node and Edge represent a Graph structure, and are coded according to
the Enhanced Node API:
Node n1 = graph.getNode(e.getFromNode().getElement());
...
ExtendedIterator<Edge> it = n1.listOutEdges();
while(n1Edge == null & it.hasNext()) {
Edge ee = it.next();
if(ee.getPropertyOfEdge().equals(n1Prop))
n1Edge = ee;
I get a ConcurrentModificationException on the hasNext() method in the
second iteration, and only when debugging. Since, apparently, no
modification is done whatsoever, I have no idea where the problem might
reside.
I also get these exceptions in other situations (not in debug mode), which
I have temporarily solved by immediately invoking the toList() method of
the iterator and then working with the list. In all these cases no
update/delete/insert (modification) is performed to the data.
Since I can no longer fix these with a "hammer", I would really appreciate
it if you could give me some help :-)
Here's the code executed inside the listOutEdges() method:
return getModel().listStatements(this, O2F.outEdge, (RDFNode) null)
.mapWith(new ObjectAsMapper(Edge.class))
.filterKeep(new ObjectNodeCanAs(Edge.class));
ObjectAsMapper and ObjectNodeCanAs are inner classes exactly as those found
in the Enhanced Node API.
Thank you!
Best,
Nuno Luz
Lately, I have been getting some ConcurrentModificationExceptions while
testing my code. I searched for possible causes but I only find (the usual
and normal) cases where some kind of inappropriate modification is
performed to the data set while iterating.
My app is currently single threaded. In this particular piece of code,
where Node and Edge represent a Graph structure, and are coded according to
the Enhanced Node API:
Node n1 = graph.getNode(e.getFromNode().getElement());
...
ExtendedIterator<Edge> it = n1.listOutEdges();
while(n1Edge == null & it.hasNext()) {
Edge ee = it.next();
if(ee.getPropertyOfEdge().equals(n1Prop))
n1Edge = ee;
I get a ConcurrentModificationException on the hasNext() method in the
second iteration, and only when debugging. Since, apparently, no
modification is done whatsoever, I have no idea where the problem might
reside.
I also get these exceptions in other situations (not in debug mode), which
I have temporarily solved by immediately invoking the toList() method of
the iterator and then working with the list. In all these cases no
update/delete/insert (modification) is performed to the data.
Since I can no longer fix these with a "hammer", I would really appreciate
it if you could give me some help :-)
Here's the code executed inside the listOutEdges() method:
return getModel().listStatements(this, O2F.outEdge, (RDFNode) null)
.mapWith(new ObjectAsMapper(Edge.class))
.filterKeep(new ObjectNodeCanAs(Edge.class));
ObjectAsMapper and ObjectNodeCanAs are inner classes exactly as those found
in the Enhanced Node API.
Thank you!
Best,
Nuno Luz