Skip to content

Commit

Permalink
When done close the temporary stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
menzowindhouwer committed Feb 15, 2017
1 parent 04678a2 commit 1ea14bd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/main/java/nl/mpi/oai/harvester/harvesting/Scenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ public boolean listIdentifiers(AbstractHarvesting harvesting) {
// apply the action sequence to the record
actionSequence.runActions(record);
}

record.close();

} finally {
if (provider.isExclusive()) {
logger.debug("release exclusive lock");
Expand Down Expand Up @@ -239,22 +242,21 @@ public boolean listRecords(AbstractHarvesting harvesting) {
if (records == null) {
return false;
} else {
//if (!harvesting.processResponse(records)) {
// return false;
//} else {
String id;
id = String.format("%07d", n);

Metadata metadata = harvesting.getMetadataFactory().create(
provider.getName() + "-" + id,
OAIHelper.getPrefix(records),
records, this.provider, true, true);

n++;

// apply the action sequence to the records
actionSequence.runActions(metadata);
//}
String id;
id = String.format("%07d", n);

Metadata metadata = harvesting.getMetadataFactory().create(
provider.getName() + "-" + id,
OAIHelper.getPrefix(records),
records, this.provider, true, true);

n++;

// apply the action sequence to the records
actionSequence.runActions(metadata);

// cleanup
metadata.close();
}
}
/* Check if in principle another response would be
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/nl/mpi/oai/harvester/metadata/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,11 @@ public void setIsInEnvelope(boolean isInEnvelope) {
public void setIsList(boolean isList) {
this.isList = isList;
}

/**
* Close the underlying streams
*/
public void close() {
this.docSrc.close();
}
}
11 changes: 11 additions & 0 deletions src/main/java/nl/mpi/oai/harvester/utils/DocumentSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,15 @@ public void setStream(InputStream str) {
this.str = str;
this.doc = null;
}

public void close() {
if (str!=null) {
try {
str.close();
} catch (IOException ex) {
logger.error(ex.getMessage(),ex);
logger.debug("failed to close stream for DocumentSource["+id+"]");
}
}
}
}
2 changes: 2 additions & 0 deletions src/main/scripts/run-harvester.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ fi
PROPS="${PROPS} -Dlogdir=${LOG_DIR}"

nice ${JAVA} ${PROPS} -jar ${JAR} $*

rm -rf /opt/oai-harvest-manager/overview.xml

0 comments on commit 1ea14bd

Please sign in to comment.