armeria
armeria copied to clipboard
Show more stack trace of CompositeException
This is an example stack trace of a CompositeException
:
com.linecorp.armeria.common.util.CompositeException: 2 exceptions occurred.
at com.linecorp.armeria.common.stream.AbstractStreamMessage$CloseEvent.notifySubscriber(AbstractStreamMessage.java:273)
at com.linecorp.armeria.common.stream.DefaultStreamMessage.notifySubscriberOfCloseEvent0(DefaultStreamMessage.java:300)
at com.linecorp.armeria.common.stream.DefaultStreamMessage.lambda$notifySubscriberOfCloseEvent$3(DefaultStreamMessage.java:294)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:391)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: com.linecorp.armeria.common.util.CompositeException$ExceptionOverview: Multiple exceptions (2)
|-- java.util.NoSuchElementException: null
at java.base/java.util.ArrayDeque.getLast(ArrayDeque.java:413)
|-- com.linecorp.armeria.common.stream.AbortedStreamException: null
at com.linecorp.armeria.common.stream.AbortedStreamException.get(AbortedStreamException.java:39)
The exceptions in ExceptionOverview
just show two lines of stack traces so it's really hard to get a context what's going on from it.
We might need to increase the lines (20 is sensible default?) and show full stack trace when -Dcom.linecorp.armeria.verboseExceptions=true
.
Can i solve this issue?
@devdynam0507 Of course, you can. 😄 Thanks in advance.
Before i begin, I have a question. Is the expected output result like below?
com.linecorp.armeria.common.util.CompositeException: 2 exceptions occurred.
at com.linecorp.armeria.common.stream.AbstractStreamMessage$CloseEvent.notifySubscriber(AbstractStreamMessage.java:273)
at com.linecorp.armeria.common.stream.DefaultStreamMessage.notifySubscriberOfCloseEvent0(DefaultStreamMessage.java:300)
at com.linecorp.armeria.common.stream.DefaultStreamMessage.lambda$notifySubscriberOfCloseEvent$3(DefaultStreamMessage.java:294)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:391)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: com.linecorp.armeria.common.util.CompositeException$ExceptionOverview: Multiple exceptions (2)
|-- java.util.NoSuchElementException: null
at java.base/java.util.ArrayDeque.getLast(ArrayDeque.java:413)
// this!
at java.some/~
at java.some/~
at java.some/~
//
....
|-- com.linecorp.armeria.common.stream.AbortedStreamException: null
at com.linecorp.armeria.common.stream.AbortedStreamException.get(AbortedStreamException.java:39)
// this!
at java.some/~
at java.some/~
at java.some/~
//
....
Yes, exactly. 😉 We need to:
- show more lines (20?) of the stack trace by default.
- show the full stack trace when the system property is enabled.
thanks for explain 😃 i have a one idea, How about printing 20 lines (or other) by default and allowing the user to set the number of lines that are output?
allowing the user to set the number of lines that are output?
That's a good suggestion. 👍 However, I'm a bit reluctant to do that because
-
CompositeException
is not something that users create by themselves - We need another system property flag to indicate the number of lines which adds another public API that might not be needed.
Therefore, how about just using the verboseExceptions
property for now? If there're demands for the number of lines later, we can add it at that time. 😄
I understood correctly! I will start working on this soon