Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.spdx</groupId>
<artifactId>java-spdx-library</artifactId>
<version>0.0.2-SNAPSHOT</version>
<version>0.0.3-SNAPSHOT</version>
<packaging>jar</packaging>

<name>java-spdx-library</name>
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/spdx/library/DefaultModelStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public static String getDefaultDocumentUri() {
public static final void reset() {
lock.writeLock().lock();
try {
if (Objects.nonNull(defaultModelStore)) {
try {
defaultModelStore.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
defaultModelStore = new InMemSpdxStore();
defaultCopyManager = new ModelCopyManager();
} finally {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/spdx/storage/IModelStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @author Gary O'Neall
*
*/
public interface IModelStore {
public interface IModelStore extends AutoCloseable {

public interface IModelStoreLock {
public void unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ InputStream getExceptionTocInputStream() throws IOException {
InputStream getExceptionInputStream(String exceptionId) throws IOException {
return getLicenseInputStream(exceptionId);
}

@Override
public void close() throws Exception {
// Nothing to do for the either the in-memory or the web store
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,9 @@ InputStream getExceptionTocInputStream() throws IOException {
InputStream getExceptionInputStream(String exceptionId) throws IOException {
return getLicenseInputStream(exceptionId); // Same URL using exception ID rather than license ID
}

@Override
public void close() throws Exception {
// Nothing to do for the either the in-memory or the web store
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/spdx/storage/simple/ExtendedSpdxStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,10 @@ protected void clear(String documentUri) throws InvalidSPDXAnalysisException {
public void delete(String documentUri, String elementId) throws InvalidSPDXAnalysisException {
baseStore.delete(documentUri, elementId);
}

@Override
public void close() throws Exception {
baseStore.close();
}

}
5 changes: 5 additions & 0 deletions src/main/java/org/spdx/storage/simple/InMemSpdxStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,9 @@ public void delete(String documentUri, String id) throws InvalidSPDXAnalysisExce
throw new SpdxIdNotFoundException("Error deleting - ID "+id+" does not exist.");
}
}

@Override
public void close() throws Exception {
// Nothing to do for the in-memory store
}
}