Skip to content

Commit 4cafffc

Browse files
authored
Merge pull request #85 from RADAR-base/tmp-dir-hotfix
Tmp dir hotfix: release 1.1.4.1
2 parents 8f33e3c + 0f62e56 commit 4cafffc

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group 'org.radarbase'
12-
version '1.1.4'
12+
version '1.1.4.1'
1313
mainClassName = 'org.radarbase.output.Application'
1414

1515
sourceCompatibility = '1.8'

src/main/java/org/radarbase/output/cleaner/SourceDataCleaner.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ class SourceDataCleaner(
6262
return try {
6363
lockManager.tryRunLocked(topic) {
6464
Accountant(fileStoreFactory, topic).use { accountant ->
65-
val extractionCheck = TimestampExtractionCheck(sourceStorage, fileStoreFactory)
66-
deleteOldFiles(accountant, extractionCheck, topic, topicPath).toLong()
65+
TimestampExtractionCheck(sourceStorage, fileStoreFactory).use { extractionCheck ->
66+
deleteOldFiles(accountant, extractionCheck, topic, topicPath).toLong()
67+
}
6768
}
6869
}
6970
} catch (ex: IOException) {

src/main/java/org/radarbase/output/cleaner/TimestampExtractionCheck.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class TimestampExtractionCheck(
4747
reader.close()
4848
}
4949

50-
5150
private fun containsRecord(topicFile: TopicFile, offset: Long, record: GenericRecord): Boolean {
5251
var suffix = 0
5352

src/main/java/org/radarbase/output/util/TemporaryDirectory.kt

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,7 @@ constructor(root: Path, prefix: String) : Closeable {
4646
private fun doClose() {
4747
try {
4848
// Ignore errors the first time
49-
Files.walk(path)
50-
.sorted(Comparator.reverseOrder())
51-
.forEach {
52-
try {
53-
Files.deleteIfExists(it)
54-
} catch (ex: Exception) {
55-
// do nothing
56-
}
57-
}
49+
deleteTree()
5850
} catch (ex: IOException) {
5951
// ignore the first time
6052
}
@@ -68,30 +60,33 @@ constructor(root: Path, prefix: String) : Closeable {
6860
Thread.currentThread().interrupt()
6961
}
7062

71-
Files.walk(path)
72-
.sorted(Comparator.reverseOrder())
73-
.forEach {
74-
try {
75-
Files.deleteIfExists(it)
76-
} catch (ex: Exception) {
77-
logger.warn("Cannot delete temporary path {}: {}",
78-
it, ex.toString())
79-
}
80-
}
63+
deleteTree()
8164
}
8265
} catch (ex: IOException) {
8366
logger.warn("Cannot delete temporary directory {}: {}", path, ex.toString())
8467
}
8568
}
8669

70+
private fun deleteTree() {
71+
Files.walk(path)
72+
.sorted(Comparator.reverseOrder())
73+
.forEach {
74+
try {
75+
Files.deleteIfExists(it)
76+
} catch (ex: Exception) {
77+
logger.warn("Cannot delete temporary path {}: {}",
78+
it, ex.toString())
79+
}
80+
}
81+
}
82+
8783
override fun close() {
8884
doClose()
8985
try {
9086
Runtime.getRuntime().removeShutdownHook(shutdownHook)
9187
} catch (ex: IllegalStateException) {
9288
// already shutting down
9389
}
94-
9590
}
9691

9792
companion object {

0 commit comments

Comments
 (0)