You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 6, 2023. It is now read-only.
* Shutdown spark server and wait until Spark is finally shut down.
12
+
*
13
+
* This is actually a rather nasty workaround to close Spark after test and ensure that it's down when we exit this method (the actual stopping is done in a separate Thread; so we have no notification about that).
14
+
* But even this does not necessarily catch all race conditions.
15
+
*/
16
+
funawaitShutdown() {
17
+
Spark.stop()
18
+
19
+
while (isLocalPortInUse(MicroserviceConfiguration.port)) {
20
+
Thread.sleep(100)
21
+
}
22
+
23
+
while (isSparkInitialized()) {
24
+
Thread.sleep(100)
25
+
}
26
+
}
27
+
28
+
/**
29
+
* Access the internals of Spark to check if the "initialized" flag is already set to false.
30
+
*/
31
+
privatefunisSparkInitialized(): Boolean {
32
+
33
+
val sparkClass =Spark::class.java
34
+
val getInstanceMethod = sparkClass.getDeclaredMethod("getInstance")
35
+
getInstanceMethod.isAccessible =true
36
+
val service = getInstanceMethod.invoke(null) asService
37
+
38
+
val serviceClass = service::class.java
39
+
val initializedField = serviceClass.getDeclaredField("initialized")
40
+
initializedField.isAccessible =true
41
+
val initialized = initializedField.getBoolean(service)
42
+
43
+
return initialized
44
+
}
45
+
46
+
/**
47
+
* Check if the Spark port could again be opened; if not, it is still in use by Spark.
0 commit comments