mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-06 06:49:53 -06:00
Cleanup when startup fails
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
This commit is contained in:
committed by
Ryan Emerson
parent
3e6d0e7026
commit
1f0683df52
@@ -345,7 +345,12 @@ public class CLITestExtension extends QuarkusMainTestExtension {
|
||||
private static InfinispanContainer configureExternalInfinispan(ExtensionContext context) {
|
||||
if (getAnnotationFromTestContext(context, WithExternalInfinispan.class) != null) {
|
||||
InfinispanContainer infinispanContainer = new InfinispanContainer();
|
||||
infinispanContainer.start();
|
||||
try {
|
||||
infinispanContainer.start();
|
||||
} catch (RuntimeException e) {
|
||||
infinispanContainer.stop();
|
||||
throw e;
|
||||
}
|
||||
return infinispanContainer;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,31 +118,6 @@ public class InfinispanContainer extends org.infinispan.server.test.core.Infinis
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void containerIsStopped(InspectContainerResponse containerInfo) {
|
||||
// This might rather be a Docker issue if the port is still blocked
|
||||
// https://github.com/docker/for-linux/issues/1180
|
||||
while(true) {
|
||||
try {
|
||||
try (Socket socket = new Socket()) {
|
||||
InetAddress inetAddress = InetAddress.getByName("localhost");
|
||||
SocketAddress socketAddress = new InetSocketAddress(inetAddress, Integer.parseInt(PORT));
|
||||
socket.bind(socketAddress);
|
||||
socket.close();
|
||||
break;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger().warn("The socket is still bound");
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
logger().info("Stopping ISPN container");
|
||||
|
||||
Reference in New Issue
Block a user