fixes ConcurrentModificationException in SimpleBridgingRule

This commit is contained in:
brianjlowe 2012-09-21 20:04:22 +00:00
parent 217cb13019
commit 4f7e6d0ee4
2 changed files with 4 additions and 8 deletions

View file

@ -1441,7 +1441,7 @@ public class SimpleReasoner extends StatementListener {
} }
} catch (Exception e) { } catch (Exception e) {
log.error("Exception while processing " + (op == ModelUpdate.Operation.ADD ? "an added" : "a removed") + log.error("Exception while processing " + (op == ModelUpdate.Operation.ADD ? "an added" : "a removed") +
" statement in SimpleReasoner plugin:" + plugin.getClass().getName() + " -- " + e.getMessage()); " statement in SimpleReasoner plugin:" + plugin.getClass().getName() + " -- ", e);
} }
} }
} }

View file

@ -2,12 +2,11 @@
package edu.cornell.mannlib.vitro.webapp.reasoner.plugin; package edu.cornell.mannlib.vitro.webapp.reasoner.plugin;
import java.util.List; import java.util.Iterator;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.graph.Graph;
import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecution;
@ -15,16 +14,13 @@ import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QueryParseException; import com.hp.hpl.jena.query.QueryParseException;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator; import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.sparql.util.graph.GraphFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.DifferenceGraph;
import edu.cornell.mannlib.vitro.webapp.reasoner.ReasonerPlugin; import edu.cornell.mannlib.vitro.webapp.reasoner.ReasonerPlugin;
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner; import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
@ -174,10 +170,10 @@ public abstract class SimpleBridgingRule implements ReasonerPlugin {
} else if (stmt.getPredicate().equals(assertedProp2)) { } else if (stmt.getPredicate().equals(assertedProp2)) {
z = stmt.getObject(); z = stmt.getObject();
} }
StmtIterator sit = aboxInferencesModel.listStatements(x, this.inferredProp, z); Iterator<Statement> sit = aboxInferencesModel.listStatements(x, this.inferredProp, z).toList().iterator();
while(sit.hasNext()) { while(sit.hasNext()) {
Statement s = sit.nextStatement(); Statement s = sit.next();
Query ask = createQuery(this.retractionTestString, stmt, s); Query ask = createQuery(this.retractionTestString, stmt, s);
QueryExecution qe = QueryExecutionFactory.create(ask, aboxAssertionsModel); QueryExecution qe = QueryExecutionFactory.create(ask, aboxAssertionsModel);
try { try {