ARTEMIS-3085 Fixing test and proper wiring listener

This commit is contained in:
Clebert Suconic 2022-12-16 05:27:18 -05:00
parent b46ccddf26
commit f5d9eed9ce
3 changed files with 15 additions and 14 deletions

View File

@ -101,7 +101,7 @@ public class NullStorageManager implements StorageManager {
@Override
public void criticalError(Throwable error) {
ioCriticalErrorListener.onIOException(error, error.getMessage(), null);
}
@Override

View File

@ -4293,6 +4293,14 @@ public class ActiveMQServerImpl implements ActiveMQServer {
return;
}
try {
for (IOCriticalErrorListener listener : ioCriticalErrorListeners) {
listener.onIOException(cause, message, file);
}
} catch (Throwable ignored) {
logger.debug("Ignored exception {}", ignored.getMessage(), ignored);
}
if (file == null) {
ActiveMQServerLogger.LOGGER.ioCriticalIOError(message, "NULL", cause);
} else {

View File

@ -16,8 +16,6 @@
*/
package org.apache.activemq.artemis.tests.integration.server;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@ -30,16 +28,11 @@ public class IOCriticalErrorListenerTest extends ActiveMQTestBase {
@Test
public void simpleTest() throws Exception {
ServerSocket s = new ServerSocket();
try {
s.bind(new InetSocketAddress("127.0.0.1", 61616));
server = createServer(false, createDefaultNettyConfig());
final CountDownLatch latch = new CountDownLatch(1);
server.registerIOCriticalErrorListener((code, message, file) -> latch.countDown());
server.start();
assertTrue(latch.await(3000, TimeUnit.MILLISECONDS));
} finally {
s.close();
}
server = createServer(false, createDefaultNettyConfig());
final CountDownLatch latch = new CountDownLatch(1);
server.registerIOCriticalErrorListener((code, message, file) -> latch.countDown());
server.start();
server.getStorageManager().criticalError(new Exception("Fake Failure"));
assertTrue(latch.await(3000, TimeUnit.MILLISECONDS));
}
}