|
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 | import org.apache.kafka.common.utils.Utils; |
51 | 52 | import org.apache.zookeeper.server.NIOServerCnxnFactory; |
@@ -283,6 +284,7 @@ public EmbeddedKafkaBroker zkSessionTimeout(int zkSessionTimeout) { |
283 | 284 |
|
284 | 285 | @Override |
285 | 286 | public void afterPropertiesSet() { |
| 287 | + overrideExitMethods(); |
286 | 288 | try { |
287 | 289 | this.zookeeper = new EmbeddedZookeeper(this.zkPort); |
288 | 290 | } |
@@ -319,6 +321,26 @@ public void afterPropertiesSet() { |
319 | 321 | System.setProperty(SPRING_EMBEDDED_ZOOKEEPER_CONNECT, getZookeeperConnectionString()); |
320 | 322 | } |
321 | 323 |
|
| 324 | + private void overrideExitMethods() { |
| 325 | + String exitMsg = "Exit.%s(%d, %s) called"; |
| 326 | + Exit.setExitProcedure((statusCode, message) -> { |
| 327 | + if (logger.isDebugEnabled()) { |
| 328 | + logger.debug(new RuntimeException(), String.format(exitMsg, "exit", statusCode, message)); |
| 329 | + } |
| 330 | + else { |
| 331 | + logger.warn(String.format(exitMsg, "exit", statusCode, message)); |
| 332 | + } |
| 333 | + }); |
| 334 | + Exit.setHaltProcedure((statusCode, message) -> { |
| 335 | + if (logger.isDebugEnabled()) { |
| 336 | + logger.debug(new RuntimeException(), String.format(exitMsg, "halt", statusCode, message)); |
| 337 | + } |
| 338 | + else { |
| 339 | + logger.warn(String.format(exitMsg, "halt", statusCode, message)); |
| 340 | + } |
| 341 | + }); |
| 342 | + } |
| 343 | + |
322 | 344 | private Properties createBrokerProperties(int i) { |
323 | 345 | return TestUtils.createBrokerConfig(i, this.zkConnect, this.controlledShutdown, |
324 | 346 | true, this.kafkaPorts[i], |
|
0 commit comments