-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: concurrent modification of rdfServiceJena getGraphURIs (#423)
Co-authored-by: Georgy Litvinov <[email protected]>
- Loading branch information
Showing
2 changed files
with
74 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...c/test/java/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/jena/RDFServiceJenaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException; | ||
import edu.cornell.mannlib.vitro.webapp.rdfservice.adapters.VitroModelFactory; | ||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel; | ||
import org.apache.jena.query.Dataset; | ||
import org.apache.jena.query.DatasetFactory; | ||
import org.apache.jena.rdf.model.Model; | ||
import org.junit.Test; | ||
|
||
public class RDFServiceJenaTest { | ||
|
||
@Test | ||
public void getConcurrentGraphUrisTest() throws RDFServiceException, InterruptedException { | ||
Dataset testDataSet = DatasetFactory.createGeneral(); | ||
Model m1 = VitroModelFactory.createModel(); | ||
testDataSet.addNamedModel("test:init1", m1); | ||
Model m2 = VitroModelFactory.createModel(); | ||
testDataSet.addNamedModel("test:init2", m2); | ||
RDFServiceJena rdfService = new RDFServiceModel(testDataSet); | ||
rdfService.getGraphURIs(); | ||
long i = 0; | ||
while (rdfService.rebuildGraphURICache) { | ||
Thread.sleep(10); | ||
i += 10; | ||
if (i > 10000) { | ||
throw new RuntimeException(); | ||
} | ||
} | ||
List<String> uris = rdfService.getGraphURIs(); | ||
for (Iterator<String> iterator = uris.iterator(); iterator.hasNext();) { | ||
Model m = VitroModelFactory.createModel(); | ||
testDataSet.addNamedModel("test" + i, m); | ||
rdfService.rebuildGraphURICache = true; | ||
rdfService.getGraphURIs(); | ||
while (rdfService.rebuildGraphURICache) { | ||
Thread.sleep(10); | ||
i += 10; | ||
if (i > 20000) { | ||
throw new RuntimeException(); | ||
} | ||
} | ||
iterator.next(); | ||
i++; | ||
} | ||
} | ||
|
||
} |