@Test public void testPop() { String contexts[] = new String[]{"1", "2"}; String errorCode = "code"; for (String context : contexts) { Error.push(context); } Error.pop(); Error e = Error.get(errorCode); Assert.assertEquals(contexts[0], e.getContext()); Assert.assertEquals(errorCode, e.getErrorCode()); Error.pop(); e = Error.get(errorCode); Assert.assertEquals("", e.getContext()); Assert.assertEquals(errorCode, e.getErrorCode()); Error.pop(); e = Error.get(errorCode); Assert.assertEquals("", e.getContext()); Assert.assertEquals(errorCode, e.getErrorCode()); Error.reset(); Error.pop(); e = Error.get(errorCode); Assert.assertEquals("", e.getContext()); Assert.assertEquals(errorCode, e.getErrorCode()); }
public static void pop() { ArrayDeque<String> c = THREAD_CONTEXT.get(); if (!c.isEmpty()) { String context = c.removeLast(); LOGGER.debug("pop: {}", context); } if (c.isEmpty()) { reset(); } }
Error extends RuntimeException { public static void pop() { ArrayDeque<String> c = THREAD_CONTEXT.get(); if (!c.isEmpty()) { String context = c.removeLast(); LOGGER.debug("pop: {}", context); } if (c.isEmpty()) { reset(); } } }
Error extends RuntimeException { public static void pop() { ArrayDeque<String> c = THREAD_CONTEXT.get(); if (!c.isEmpty()) { String context = c.removeLast(); LOGGER.debug("pop: {}", context); } if (c.isEmpty()) { reset(); } } private  Error(String errorCode, String msg); private  Error(ArrayDeque<String> context, String errorCode, String msg); }
Error extends RuntimeException { public static void pop() { ArrayDeque<String> c = THREAD_CONTEXT.get(); if (!c.isEmpty()) { String context = c.removeLast(); LOGGER.debug("pop: {}", context); } if (c.isEmpty()) { reset(); } } private  Error(String errorCode, String msg); private  Error(ArrayDeque<String> context, String errorCode, String msg); static void push(String context); static void pop(); static Error get(String ctx, String errorCode, String msg); static Error get(String ctx, String errorCode, Throwable e); static Error get(String errorCode, String msg); static Error get(String errorCode, Throwable e); static Error get(Throwable e); static Error get(String errorCode); static void reset(); void pushContext(String context); void popContext(); String getErrorCode(); String getMsg(); String getContext(); JsonNode toJson(); @Override String toString(); @Override String getMessage(); static Error fromJson(JsonNode node); }
Error extends RuntimeException { public static void pop() { ArrayDeque<String> c = THREAD_CONTEXT.get(); if (!c.isEmpty()) { String context = c.removeLast(); LOGGER.debug("pop: {}", context); } if (c.isEmpty()) { reset(); } } private  Error(String errorCode, String msg); private  Error(ArrayDeque<String> context, String errorCode, String msg); static void push(String context); static void pop(); static Error get(String ctx, String errorCode, String msg); static Error get(String ctx, String errorCode, Throwable e); static Error get(String errorCode, String msg); static Error get(String errorCode, Throwable e); static Error get(Throwable e); static Error get(String errorCode); static void reset(); void pushContext(String context); void popContext(); String getErrorCode(); String getMsg(); String getContext(); JsonNode toJson(); @Override String toString(); @Override String getMessage(); static Error fromJson(JsonNode node); static final char DELIMITER; }