[ 
https://issues.apache.org/jira/browse/JENA-1521?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andy Seaborne updated JENA-1521:
--------------------------------
    Description: 
If a Dataset connected to with TDB2Factory.connectDataset() is opened, closed 
and then later re-opened it is reported that the Dataset is closed.

Opening, closing and re-opening a Dataset with TDBFactory.createDataset() 
causes no issues.

Example code to reproduce:
{noformat}
public void testTDB2OpenClose() {

System.out.println("TDB2 Open Close");
 try {
 Dataset dataset = TDB2Factory.connectDataset("test_tdb2");
 dataset.begin(ReadWrite.WRITE);
 Model defaultModel = dataset.getDefaultModel();
 
defaultModel.add(ResourceFactory.createResource("http://example.org/my#SubjA";), 
ResourceFactory.createProperty("http://example.org/my#PropA";), 
ResourceFactory.createResource("http://example.org/my#ObjA";));
 dataset.commit();
 dataset.end();
 dataset.close();

Dataset dataset2 = TDB2Factory.connectDataset("test_tdb2");
 dataset2.begin(ReadWrite.READ);
 Model readModel = dataset2.getDefaultModel();
 Iterator<Statement> statements = readModel.listStatements();
 while (statements.hasNext())

{ Statement statement = statements.next(); System.out.println(statement); }
 dataset2.end();
 dataset2.close();
 } catch (Exception ex) \{ System.out.println("Exception: " + ex.getMessage()); 
}
 }
 {noformat}

{noformat}
 public void testTDB1OpenClose() {
 
 System.out.println("TDB1 Open Close");
 try {
 Dataset dataset = TDBFactory.createDataset("test_tdb1");
 dataset.begin(ReadWrite.WRITE);
 Model defaultModel = dataset.getDefaultModel();
 
defaultModel.add(ResourceFactory.createResource("http://example.org/my#SubjA";), 
ResourceFactory.createProperty("http://example.org/my#PropA";), 
ResourceFactory.createResource("http://example.org/my#ObjA";));
 dataset.commit();
 dataset.end();
 dataset.close();
 
 Dataset dataset2 = TDBFactory.createDataset("test_tdb1");
 dataset2.begin(ReadWrite.READ);
 Model readModel = dataset2.getDefaultModel();
 Iterator<Statement> statements = readModel.listStatements();
 while (statements.hasNext()) \{ Statement statement = statements.next(); 
System.out.println(statement); }

dataset2.end();
 dataset2.close();
 } catch (Exception ex)

{ System.out.println("Exception: " + ex.getMessage()); }

}
{noformat}
 

  was:
If a Dataset connected to with TDB2Factory.connectDataset() is opened, closed 
and then later re-opened it is reported that the Dataset is closed.

Opening, closing and re-opening a Dataset with TDBFactory.createDataset() 
causes no issues.

Example code to reproduce:

public void testTDB2OpenClose() {

System.out.println("TDB2 Open Close");
 try {
 Dataset dataset = TDB2Factory.connectDataset("test_tdb2");
 dataset.begin(ReadWrite.WRITE);
 Model defaultModel = dataset.getDefaultModel();
 
defaultModel.add(ResourceFactory.createResource("http://example.org/my#SubjA";), 
ResourceFactory.createProperty("http://example.org/my#PropA";), 
ResourceFactory.createResource("http://example.org/my#ObjA";));
 dataset.commit();
 dataset.end();
 dataset.close();

Dataset dataset2 = TDB2Factory.connectDataset("test_tdb2");
 dataset2.begin(ReadWrite.READ);
 Model readModel = dataset2.getDefaultModel();
 Iterator<Statement> statements = readModel.listStatements();
 while (statements.hasNext()) {
 Statement statement = statements.next();
 System.out.println(statement);
 }
 dataset2.end();
 dataset2.close();
 } catch (Exception ex) {
 System.out.println("Exception: " + ex.getMessage());
 }
 }


 public void testTDB1OpenClose() {

System.out.println("TDB1 Open Close");
 try {
 Dataset dataset = TDBFactory.createDataset("test_tdb1");
 dataset.begin(ReadWrite.WRITE);
 Model defaultModel = dataset.getDefaultModel();
 
defaultModel.add(ResourceFactory.createResource("http://example.org/my#SubjA";), 
ResourceFactory.createProperty("http://example.org/my#PropA";), 
ResourceFactory.createResource("http://example.org/my#ObjA";));
 dataset.commit();
 dataset.end();
 dataset.close();

Dataset dataset2 = TDBFactory.createDataset("test_tdb1");
 dataset2.begin(ReadWrite.READ);
 Model readModel = dataset2.getDefaultModel();
 Iterator<Statement> statements = readModel.listStatements();
 while (statements.hasNext()) {
 Statement statement = statements.next();
 System.out.println(statement);
 }
 dataset2.end();
 dataset2.close();
 } catch (Exception ex) {
 System.out.println("Exception: " + ex.getMessage());
 }
 }

 


> TDB2 backed Datasets cannot be re-opened.
> -----------------------------------------
>
>                 Key: JENA-1521
>                 URL: https://issues.apache.org/jira/browse/JENA-1521
>             Project: Apache Jena
>          Issue Type: Bug
>         Environment: Apache Jena: 3.7.0
> Java: 1.8_162
>            Reporter: Greg Albiston
>            Priority: Major
>
> If a Dataset connected to with TDB2Factory.connectDataset() is opened, closed 
> and then later re-opened it is reported that the Dataset is closed.
> Opening, closing and re-opening a Dataset with TDBFactory.createDataset() 
> causes no issues.
> Example code to reproduce:
> {noformat}
> public void testTDB2OpenClose() {
> System.out.println("TDB2 Open Close");
>  try {
>  Dataset dataset = TDB2Factory.connectDataset("test_tdb2");
>  dataset.begin(ReadWrite.WRITE);
>  Model defaultModel = dataset.getDefaultModel();
>  
> defaultModel.add(ResourceFactory.createResource("http://example.org/my#SubjA";),
>  ResourceFactory.createProperty("http://example.org/my#PropA";), 
> ResourceFactory.createResource("http://example.org/my#ObjA";));
>  dataset.commit();
>  dataset.end();
>  dataset.close();
> Dataset dataset2 = TDB2Factory.connectDataset("test_tdb2");
>  dataset2.begin(ReadWrite.READ);
>  Model readModel = dataset2.getDefaultModel();
>  Iterator<Statement> statements = readModel.listStatements();
>  while (statements.hasNext())
> { Statement statement = statements.next(); System.out.println(statement); }
>  dataset2.end();
>  dataset2.close();
>  } catch (Exception ex) \{ System.out.println("Exception: " + 
> ex.getMessage()); }
>  }
>  {noformat}
> {noformat}
>  public void testTDB1OpenClose() {
>  
>  System.out.println("TDB1 Open Close");
>  try {
>  Dataset dataset = TDBFactory.createDataset("test_tdb1");
>  dataset.begin(ReadWrite.WRITE);
>  Model defaultModel = dataset.getDefaultModel();
>  
> defaultModel.add(ResourceFactory.createResource("http://example.org/my#SubjA";),
>  ResourceFactory.createProperty("http://example.org/my#PropA";), 
> ResourceFactory.createResource("http://example.org/my#ObjA";));
>  dataset.commit();
>  dataset.end();
>  dataset.close();
>  
>  Dataset dataset2 = TDBFactory.createDataset("test_tdb1");
>  dataset2.begin(ReadWrite.READ);
>  Model readModel = dataset2.getDefaultModel();
>  Iterator<Statement> statements = readModel.listStatements();
>  while (statements.hasNext()) \{ Statement statement = statements.next(); 
> System.out.println(statement); }
> dataset2.end();
>  dataset2.close();
>  } catch (Exception ex)
> { System.out.println("Exception: " + ex.getMessage()); }
> }
> {noformat}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to