Skip to content

Commit 9386082

Browse files
robsymepditommaso
andauthored
Fix Only close the cache db if it is not null (#5631)
Signed-off-by: Rob Syme <[email protected]> Co-authored-by: Paolo Di Tommaso <[email protected]>
1 parent 884f745 commit 9386082

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

modules/nextflow/src/main/groovy/nextflow/Session.groovy

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,10 +1209,8 @@ class Session implements ISession {
12091209
if( aborted || cancelled || error )
12101210
return
12111211

1212-
CacheDB db = null
1213-
try {
1214-
log.trace "Cleaning-up workdir"
1215-
db = CacheFactory.create(uniqueId, runName).openForRead()
1212+
log.trace "Cleaning-up workdir"
1213+
try (CacheDB db = CacheFactory.create(uniqueId, runName).openForRead()) {
12161214
db.eachRecord { HashCode hash, TraceRecord record ->
12171215
def deleted = db.removeTaskEntry(hash)
12181216
if( deleted ) {
@@ -1223,10 +1221,7 @@ class Session implements ISession {
12231221
log.trace "Clean workdir complete"
12241222
}
12251223
catch( Exception e ) {
1226-
log.warn("Failed to cleanup work dir: ${workDir.toUriString()}")
1227-
}
1228-
finally {
1229-
db.close()
1224+
log.warn("Failed to cleanup work dir: ${workDir.toUriString()}", e)
12301225
}
12311226
}
12321227

0 commit comments

Comments
 (0)