From f1d85d2ba26bb68e8b573f26e100a98c8b945a2a Mon Sep 17 00:00:00 2001 From: Seoyoung Park Date: Wed, 20 Nov 2024 17:09:35 +0900 Subject: [PATCH] [#noissue] Fix `testRecordNotChainedException` test failure --- .../DefaultExceptionRecorderTest.java | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/agent-module/profiler/src/test/java/com/navercorp/pinpoint/profiler/metadata/DefaultExceptionRecorderTest.java b/agent-module/profiler/src/test/java/com/navercorp/pinpoint/profiler/metadata/DefaultExceptionRecorderTest.java index 75663dd9d957..c02fe6e77284 100644 --- a/agent-module/profiler/src/test/java/com/navercorp/pinpoint/profiler/metadata/DefaultExceptionRecorderTest.java +++ b/agent-module/profiler/src/test/java/com/navercorp/pinpoint/profiler/metadata/DefaultExceptionRecorderTest.java @@ -40,14 +40,13 @@ public class DefaultExceptionRecorderTest { private final static Logger logger = LogManager.getLogger(DefaultExceptionRecorderTest.class); + private final static long START_TIME = 1; ExceptionChainSampler exceptionChainSampler = new ExceptionChainSampler(1000); ExceptionWrapperFactory exceptionWrapperFactory = new ExceptionWrapperFactory(10, 1048); - long START_TIME = 1; - - class TestExceptionStorage implements ExceptionStorage { + static class TestExceptionStorage implements ExceptionStorage { List wrappers; public List outputStream; @@ -59,7 +58,7 @@ public TestExceptionStorage() { @Override public void store(List wrappers) { - logger.error(wrappers); + logger.info(wrappers); this.wrappers.addAll(wrappers); } @@ -85,7 +84,7 @@ public List getOutputStream() { } } - private Function getThrowableFunction( + private static Function getThrowableFunction( DefaultExceptionRecorder recorder, List throwable ) { @@ -112,11 +111,11 @@ public void testRecordNothing() { DefaultExceptionRecorder exceptionRecorder = new DefaultExceptionRecorder( exceptionChainSampler, exceptionWrapperFactory, context ); - Function throwableFunction = getThrowableFunction( + Function recordThrowable = getThrowableFunction( exceptionRecorder, exceptions ); - exceptionRecorder.recordException(null, 0); + recordThrowable.apply(null); exceptionRecorder.close(); List expected = new ArrayList<>(); @@ -133,7 +132,7 @@ public void testRecordException() { DefaultExceptionRecorder exceptionRecorder = new DefaultExceptionRecorder( exceptionChainSampler, exceptionWrapperFactory, context ); - Function throwableFunction = getThrowableFunction( + Function recordThrowable = getThrowableFunction( exceptionRecorder, exceptions ); @@ -141,10 +140,10 @@ public void testRecordException() { List actual = null; try { - level3Error(throwableFunction); + level3Error(recordThrowable); } catch (Throwable e) { expected = newExceptionWrappers(e, START_TIME, 1); - exceptionRecorder.recordException(e, START_TIME); + recordThrowable.apply(e); actual = exceptionStorage.getWrappers(); Assertions.assertTrue(actual.isEmpty()); } @@ -161,7 +160,7 @@ public void testRecordNotChainedException() { DefaultExceptionRecorder exceptionRecorder = new DefaultExceptionRecorder( exceptionChainSampler, exceptionWrapperFactory, context ); - Function throwableFunction = getThrowableFunction( + Function recordThrowable = getThrowableFunction( exceptionRecorder, exceptions ); @@ -173,10 +172,9 @@ public void testRecordNotChainedException() { Throwable throwable = null; try { - notChainedException(throwableFunction); + notChainedException(recordThrowable); } catch (Throwable e) { expected1 = newExceptionWrappers(exceptions.get(exceptions.size() - 2), START_TIME, 1); - exceptionRecorder.recordException(e, START_TIME); logger.warn(exceptionStorage.getWrappers()); actual1 = new ArrayList<>(exceptionStorage.getWrappers()); throwable = e; @@ -204,7 +202,7 @@ public void testRecordRethrowGivenException() { DefaultExceptionRecorder exceptionRecorder = new DefaultExceptionRecorder( exceptionChainSampler, exceptionWrapperFactory, context ); - Function throwableFunction = getThrowableFunction( + Function recordThrowable = getThrowableFunction( exceptionRecorder, exceptions ); @@ -212,10 +210,9 @@ public void testRecordRethrowGivenException() { List actual = null; try { - rethrowGivenException(throwableFunction); + rethrowGivenException(recordThrowable); } catch (Throwable e) { expected = newExceptionWrappers(e, START_TIME, 1); - exceptionRecorder.recordException(e, START_TIME); actual = exceptionStorage.getWrappers(); Assertions.assertTrue(actual.isEmpty()); }