|
46 | 46 | import org.apache.kafka.clients.consumer.ConsumerRecords; |
47 | 47 | import org.apache.kafka.common.TopicPartition; |
48 | 48 | import org.apache.kafka.common.security.auth.SecurityProtocol; |
| 49 | +import org.apache.kafka.common.utils.Exit; |
49 | 50 | import org.apache.kafka.common.utils.Time; |
50 | 51 |
|
51 | 52 | import org.springframework.beans.factory.DisposableBean; |
@@ -202,6 +203,7 @@ public void setAdminTimeout(int adminTimeout) { |
202 | 203 |
|
203 | 204 | @Override |
204 | 205 | public void afterPropertiesSet() { |
| 206 | + overrideExitMethods(); |
205 | 207 | this.zookeeper = new EmbeddedZookeeper(); |
206 | 208 | int zkConnectionTimeout = 6000; // NOSONAR magic # |
207 | 209 | int zkSessionTimeout = 6000; // NOSONAR magic # |
@@ -235,6 +237,26 @@ public void afterPropertiesSet() { |
235 | 237 | System.setProperty(SPRING_EMBEDDED_ZOOKEEPER_CONNECT, getZookeeperConnectionString()); |
236 | 238 | } |
237 | 239 |
|
| 240 | + private void overrideExitMethods() { |
| 241 | + String exitMsg = "Exit.%s(%d, %s) called"; |
| 242 | + Exit.setExitProcedure((statusCode, message) -> { |
| 243 | + if (logger.isDebugEnabled()) { |
| 244 | + logger.debug(new RuntimeException(), String.format(exitMsg, "exit", statusCode, message)); |
| 245 | + } |
| 246 | + else { |
| 247 | + logger.warn(String.format(exitMsg, "exit", statusCode, message)); |
| 248 | + } |
| 249 | + }); |
| 250 | + Exit.setHaltProcedure((statusCode, message) -> { |
| 251 | + if (logger.isDebugEnabled()) { |
| 252 | + logger.debug(new RuntimeException(), String.format(exitMsg, "halt", statusCode, message)); |
| 253 | + } |
| 254 | + else { |
| 255 | + logger.warn(String.format(exitMsg, "halt", statusCode, message)); |
| 256 | + } |
| 257 | + }); |
| 258 | + } |
| 259 | + |
238 | 260 | private Properties createBrokerProperties(int i) { |
239 | 261 | return TestUtils.createBrokerConfig(i, this.zkConnect, this.controlledShutdown, |
240 | 262 | true, this.kafkaPorts[i], |
|
0 commit comments