|
44 | 44 | import org.apache.kafka.clients.consumer.ConsumerRecords; |
45 | 45 | import org.apache.kafka.common.TopicPartition; |
46 | 46 | import org.apache.kafka.common.security.auth.SecurityProtocol; |
| 47 | +import org.apache.kafka.common.utils.Exit; |
47 | 48 | import org.apache.kafka.common.utils.Time; |
48 | 49 | import org.apache.kafka.common.utils.Utils; |
49 | 50 | import org.apache.zookeeper.server.NIOServerCnxnFactory; |
@@ -278,6 +279,7 @@ public synchronized EmbeddedKafkaBroker zkSessionTimeout(int zkSessionTimeout) { |
278 | 279 |
|
279 | 280 | @Override |
280 | 281 | public void afterPropertiesSet() { |
| 282 | + overrideExitMethods(); |
281 | 283 | try { |
282 | 284 | this.zookeeper = new EmbeddedZookeeper(this.zkPort); |
283 | 285 | } |
@@ -314,6 +316,26 @@ public void afterPropertiesSet() { |
314 | 316 | System.setProperty(SPRING_EMBEDDED_ZOOKEEPER_CONNECT, getZookeeperConnectionString()); |
315 | 317 | } |
316 | 318 |
|
| 319 | + private void overrideExitMethods() { |
| 320 | + String exitMsg = "Exit.%s(%d, %s) called"; |
| 321 | + Exit.setExitProcedure((statusCode, message) -> { |
| 322 | + if (logger.isDebugEnabled()) { |
| 323 | + logger.debug(new RuntimeException(), String.format(exitMsg, "exit", statusCode, message)); |
| 324 | + } |
| 325 | + else { |
| 326 | + logger.warn(String.format(exitMsg, "exit", statusCode, message)); |
| 327 | + } |
| 328 | + }); |
| 329 | + Exit.setHaltProcedure((statusCode, message) -> { |
| 330 | + if (logger.isDebugEnabled()) { |
| 331 | + logger.debug(new RuntimeException(), String.format(exitMsg, "halt", statusCode, message)); |
| 332 | + } |
| 333 | + else { |
| 334 | + logger.warn(String.format(exitMsg, "halt", statusCode, message)); |
| 335 | + } |
| 336 | + }); |
| 337 | + } |
| 338 | + |
317 | 339 | private Properties createBrokerProperties(int i) { |
318 | 340 | return TestUtils.createBrokerConfig(i, this.zkConnect, this.controlledShutdown, |
319 | 341 | true, this.kafkaPorts[i], |
|
0 commit comments