Skip to content

Commit de128c3

Browse files
committed
Ensure that exceptions gets thrown
1 parent 5ef86be commit de128c3

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

src/main/java/org/radarbase/output/Application.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ package org.radarbase.output
1818

1919
import com.beust.jcommander.JCommander
2020
import com.beust.jcommander.ParameterException
21-
import kotlinx.coroutines.launch
22-
import kotlinx.coroutines.runBlocking
21+
import kotlinx.coroutines.*
2322
import kotlinx.coroutines.sync.Mutex
2423
import kotlinx.coroutines.sync.Semaphore
2524
import org.radarbase.output.accounting.*
@@ -200,9 +199,17 @@ class Application(
200199
} catch (e: IllegalStateException) {
201200
logger.error("Invalid configuration: {}", e.message)
202201
exitProcess(1)
202+
} catch (ex: Throwable) {
203+
logger.error("Failed to initialize application: {}", ex.message)
204+
exitProcess(1)
203205
}
204206

205-
application.start()
207+
try {
208+
application.start()
209+
} catch (ex: Throwable) {
210+
logger.error("Application failed: {}", ex.message)
211+
exitProcess(1)
212+
}
206213
}
207214
}
208215
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.radarbase.output.source
2+
3+
import kotlinx.coroutines.launch
4+
import kotlinx.coroutines.runBlocking
5+
import org.junit.jupiter.api.Test
6+
import org.junit.jupiter.api.assertThrows
7+
import org.radarbase.output.source.S3SourceStorage.Companion.faultTolerant
8+
import java.io.IOException
9+
10+
class S3SourceStorageTest {
11+
@Test
12+
fun testSuspend() {
13+
assertThrows<IOException> {
14+
runBlocking {
15+
launch { throw IOException("ex") }
16+
}
17+
}
18+
}
19+
@Test
20+
fun testFaultTolerant() {
21+
assertThrows<IOException> {
22+
runBlocking {
23+
faultTolerant { throw IOException("test") }
24+
}
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)