ConsumerExceptionHandler implements ExceptionHandler<SofaTracerSpanEvent> { @Override public void handleEventException(Throwable ex, long sequence, SofaTracerSpanEvent event) { if (event != null) { SofaTracerSpan sofaTracerSpan = event.getSofaTracerSpan(); SynchronizingSelfLog.error( "AsyncConsumer occurs exception during handle SofaTracerSpanEvent, The sofaTracerSpan is[" + sofaTracerSpan + "]", ex); } else { SynchronizingSelfLog .error( "AsyncConsumer occurs exception during handle SofaTracerSpanEvent, The sofaTracerSpan is null", ex); } }  @Override void handleEventException(Throwable ex, long sequence, SofaTracerSpanEvent event); @Override void handleOnStartException(Throwable ex); @Override void handleOnShutdownException(Throwable ex);  }
@Test public void handleEventExceptionWithEventNull() throws IOException, InterruptedException { consumerExceptionHandler.handleEventException(new Throwable(), 1, null); TestUtil.waitForAsyncLog(); File log = customFileLog("sync.log"); List<String> logs = FileUtils.readLines(log); assertTrue(logs.toString(), logs.get(0).contains("[ERROR]")); }
@Test public void handleEventExceptionWithEventNotNull() throws IOException, InterruptedException { sofaTracerSpanEvent.setSofaTracerSpan(sofaTracerSpan); consumerExceptionHandler.handleEventException(new Throwable(), 1, sofaTracerSpanEvent); TestUtil.waitForAsyncLog(); File log = customFileLog("sync.log"); List<String> logs = FileUtils.readLines(log); assertTrue(logs.toString(), logs.get(0).contains("[ERROR]")); }