Cleanup when startup fails

Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
This commit is contained in:
Alexander Schwartz
2025-10-16 16:40:31 +02:00
committed by Ryan Emerson
parent 3e6d0e7026
commit 1f0683df52
2 changed files with 6 additions and 26 deletions

View File

@@ -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;
}

View File

@@ -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");