public class ThrowableProxy
extends java.lang.Object
implements java.io.Serializable
A proxy is used to represent a throwable that may not exist in a different class loader or JVM. When an application deserializes a ThrowableProxy, the throwable may not be set, but the throwable's information is preserved in other fields of the proxy like the message and stack trace.
TODO: Move this class to org.apache.logging.log4j.core because it is used from LogEvent.
TODO: Deserialize: Try to rebuild Throwable if the target exception is in this class loader?
Modifier and Type | Field and Description |
---|---|
private ThrowableProxy |
causeProxy |
private int |
commonElementCount |
private static char |
EOL |
private static java.lang.String |
EOL_STR |
private ExtendedStackTraceElement[] |
extendedStackTrace |
private java.lang.String |
localizedMessage |
private java.lang.String |
message |
private java.lang.String |
name |
private static long |
serialVersionUID |
private ThrowableProxy[] |
suppressedProxies |
private java.lang.Throwable |
throwable |
Modifier | Constructor and Description |
---|---|
private |
ThrowableProxy()
For JSON and XML IO via Jackson.
|
|
ThrowableProxy(java.lang.Throwable throwable)
Constructs the wrapper for the Throwable that includes packaging data.
|
(package private) |
ThrowableProxy(java.lang.Throwable throwable,
java.util.Set<java.lang.Throwable> visited)
Constructs the wrapper for the Throwable that includes packaging data.
|
private |
ThrowableProxy(java.lang.Throwable parent,
java.util.Stack<java.lang.Class<?>> stack,
java.util.Map<java.lang.String,ThrowableProxyHelper.CacheEntry> map,
java.lang.Throwable cause,
java.util.Set<java.lang.Throwable> suppressedVisited,
java.util.Set<java.lang.Throwable> causeVisited)
Constructs the wrapper for a Throwable that is referenced as the cause by another Throwable.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
void |
formatExtendedStackTraceTo(java.lang.StringBuilder sb,
java.util.List<java.lang.String> ignorePackages,
TextRenderer textRenderer,
java.lang.String suffix,
java.lang.String lineSeparator)
Formats the stack trace including packaging information.
|
void |
formatWrapper(java.lang.StringBuilder sb,
ThrowableProxy cause,
java.util.List<java.lang.String> ignorePackages,
java.lang.String suffix)
Formats the specified Throwable.
|
void |
formatWrapper(java.lang.StringBuilder sb,
ThrowableProxy cause,
java.util.List<java.lang.String> ignorePackages,
TextRenderer textRenderer,
java.lang.String suffix)
Formats the specified Throwable.
|
void |
formatWrapper(java.lang.StringBuilder sb,
ThrowableProxy cause,
java.util.List<java.lang.String> ignorePackages,
TextRenderer textRenderer,
java.lang.String suffix,
java.lang.String lineSeparator)
Formats the specified Throwable.
|
void |
formatWrapper(java.lang.StringBuilder sb,
ThrowableProxy cause,
java.lang.String suffix)
Formats the specified Throwable.
|
ThrowableProxy |
getCauseProxy() |
java.lang.String |
getCauseStackTraceAsString(java.util.List<java.lang.String> packages,
java.lang.String suffix)
Formats the Throwable that is the cause of this Throwable.
|
java.lang.String |
getCauseStackTraceAsString(java.util.List<java.lang.String> ignorePackages,
TextRenderer textRenderer,
java.lang.String suffix)
Formats the Throwable that is the cause of this Throwable.
|
java.lang.String |
getCauseStackTraceAsString(java.util.List<java.lang.String> ignorePackages,
TextRenderer textRenderer,
java.lang.String suffix,
java.lang.String lineSeparator)
Formats the Throwable that is the cause of this Throwable.
|
java.lang.String |
getCauseStackTraceAsString(java.lang.String suffix)
Formats the Throwable that is the cause of this Throwable.
|
int |
getCommonElementCount()
Returns the number of elements that are being omitted because they are common with the parent Throwable's stack
trace.
|
ExtendedStackTraceElement[] |
getExtendedStackTrace()
Gets the stack trace including packaging information.
|
java.lang.String |
getExtendedStackTraceAsString()
Formats the stack trace including packaging information.
|
java.lang.String |
getExtendedStackTraceAsString(java.util.List<java.lang.String> ignorePackages,
java.lang.String suffix)
Formats the stack trace including packaging information.
|
java.lang.String |
getExtendedStackTraceAsString(java.util.List<java.lang.String> ignorePackages,
TextRenderer textRenderer,
java.lang.String suffix)
Formats the stack trace including packaging information.
|
java.lang.String |
getExtendedStackTraceAsString(java.util.List<java.lang.String> ignorePackages,
TextRenderer textRenderer,
java.lang.String suffix,
java.lang.String lineSeparator)
Formats the stack trace including packaging information.
|
java.lang.String |
getExtendedStackTraceAsString(java.lang.String suffix)
Formats the stack trace including packaging information.
|
java.lang.String |
getLocalizedMessage() |
java.lang.String |
getMessage() |
java.lang.String |
getName()
Return the FQCN of the Throwable.
|
java.lang.StackTraceElement[] |
getStackTrace() |
ThrowableProxy[] |
getSuppressedProxies()
Gets proxies for suppressed exceptions.
|
java.lang.String |
getSuppressedStackTrace(java.lang.String suffix)
Formats the suppressed Throwables.
|
java.lang.Throwable |
getThrowable()
The throwable or null if this object is deserialized from XML or JSON.
|
int |
hashCode() |
(package private) void |
setCommonElementCount(int value)
Set the value of
commonElementCount . |
java.lang.String |
toString() |
private static final char EOL
private static final java.lang.String EOL_STR
private static final long serialVersionUID
private final ThrowableProxy causeProxy
private int commonElementCount
private final ExtendedStackTraceElement[] extendedStackTrace
private final java.lang.String localizedMessage
private final java.lang.String message
private final java.lang.String name
private final ThrowableProxy[] suppressedProxies
private final transient java.lang.Throwable throwable
private ThrowableProxy()
public ThrowableProxy(java.lang.Throwable throwable)
throwable
- The Throwable to wrap, must not be null.ThrowableProxy(java.lang.Throwable throwable, java.util.Set<java.lang.Throwable> visited)
throwable
- The Throwable to wrap, must not be null.visited
- The set of visited suppressed exceptions.private ThrowableProxy(java.lang.Throwable parent, java.util.Stack<java.lang.Class<?>> stack, java.util.Map<java.lang.String,ThrowableProxyHelper.CacheEntry> map, java.lang.Throwable cause, java.util.Set<java.lang.Throwable> suppressedVisited, java.util.Set<java.lang.Throwable> causeVisited)
parent
- The Throwable referencing this Throwable.stack
- The Class stack.map
- The cache containing the packaging data.cause
- The Throwable to wrap.suppressedVisited
- TODOcauseVisited
- TODOpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public void formatWrapper(java.lang.StringBuilder sb, ThrowableProxy cause, java.lang.String suffix)
sb
- StringBuilder to contain the formatted Throwable.cause
- The Throwable to format.suffix
- public void formatWrapper(java.lang.StringBuilder sb, ThrowableProxy cause, java.util.List<java.lang.String> ignorePackages, java.lang.String suffix)
sb
- StringBuilder to contain the formatted Throwable.cause
- The Throwable to format.ignorePackages
- The List of packages to be suppressed from the trace.suffix
- public void formatWrapper(java.lang.StringBuilder sb, ThrowableProxy cause, java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix)
sb
- StringBuilder to contain the formatted Throwable.cause
- The Throwable to format.ignorePackages
- The List of packages to be suppressed from the stack trace.textRenderer
- The text renderer.suffix
- Append this to the end of each stack frame.public void formatWrapper(java.lang.StringBuilder sb, ThrowableProxy cause, java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix, java.lang.String lineSeparator)
sb
- StringBuilder to contain the formatted Throwable.cause
- The Throwable to format.ignorePackages
- The List of packages to be suppressed from the stack trace.textRenderer
- The text renderer.suffix
- Append this to the end of each stack frame.lineSeparator
- The end-of-line separator.public ThrowableProxy getCauseProxy()
public java.lang.String getCauseStackTraceAsString(java.lang.String suffix)
suffix
- public java.lang.String getCauseStackTraceAsString(java.util.List<java.lang.String> packages, java.lang.String suffix)
packages
- The List of packages to be suppressed from the trace.suffix
- Append this to the end of each stack frame.public java.lang.String getCauseStackTraceAsString(java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix)
ignorePackages
- The List of packages to be suppressed from the trace.textRenderer
- The text renderer.suffix
- Append this to the end of each stack frame.public java.lang.String getCauseStackTraceAsString(java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix, java.lang.String lineSeparator)
ignorePackages
- The List of packages to be suppressed from the stack trace.textRenderer
- The text renderer.suffix
- Append this to the end of each stack frame.lineSeparator
- The end-of-line separator.public int getCommonElementCount()
void setCommonElementCount(int value)
commonElementCount
.
Method is package-private, to be used internally for initialization.value
- New value of commonElementCount.public ExtendedStackTraceElement[] getExtendedStackTrace()
public java.lang.String getExtendedStackTraceAsString()
public java.lang.String getExtendedStackTraceAsString(java.lang.String suffix)
suffix
- Append this to the end of each stack frame.public java.lang.String getExtendedStackTraceAsString(java.util.List<java.lang.String> ignorePackages, java.lang.String suffix)
ignorePackages
- List of packages to be ignored in the trace.suffix
- Append this to the end of each stack frame.public java.lang.String getExtendedStackTraceAsString(java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix)
ignorePackages
- List of packages to be ignored in the trace.textRenderer
- The message renderer.suffix
- Append this to the end of each stack frame.public java.lang.String getExtendedStackTraceAsString(java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix, java.lang.String lineSeparator)
ignorePackages
- List of packages to be ignored in the trace.textRenderer
- The message renderer.suffix
- Append this to the end of each stack frame.lineSeparator
- The end-of-line separator.public void formatExtendedStackTraceTo(java.lang.StringBuilder sb, java.util.List<java.lang.String> ignorePackages, TextRenderer textRenderer, java.lang.String suffix, java.lang.String lineSeparator)
sb
- Destination.ignorePackages
- List of packages to be ignored in the trace.textRenderer
- The message renderer.suffix
- Append this to the end of each stack frame.lineSeparator
- The end-of-line separator.public java.lang.String getLocalizedMessage()
public java.lang.String getMessage()
public java.lang.String getName()
public java.lang.StackTraceElement[] getStackTrace()
public ThrowableProxy[] getSuppressedProxies()
public java.lang.String getSuppressedStackTrace(java.lang.String suffix)
suffix
- public java.lang.Throwable getThrowable()
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object