Package org.apache.juneau.rest.stats
Class ThrownStore
java.lang.Object
org.apache.juneau.rest.stats.ThrownStore
An in-memory cache of thrown exceptions.
Used for preventing duplication of stack traces in log files and replacing them with small hashes.
See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ThrownStore
Identifies a single global store for the entire JVM. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds the specified thrown exception to this database.static ThrownStore.Builder
create()
Static creator.static ThrownStore.Builder
Static creator.Converts the stack trace for the specified throwable into a simple list of strings.getStats()
Returns the list of all stack traces in this database.getStats
(long hash) Retrieves the stack trace information for the exception with the specified hash as calculated byhash(Throwable)
.Retrieves the stats for the specified thrown exception.protected long
Calculates a 32-bit hash for the specified throwable based on the stack trace generated bycreateStackTrace(Throwable)
.protected boolean
Returnstrue if the specified stack trace element should be included increateStackTrace(Throwable)
.protected String
Converts the specified stack trace element into a normalized string.void
reset()
Clears out the stack trace cache.
-
Field Details
-
GLOBAL
Identifies a single global store for the entire JVM.
-
-
Constructor Details
-
ThrownStore
public ThrownStore()Constructor. -
ThrownStore
Constructor.- Parameters:
builder
- The builder for this object.
-
-
Method Details
-
create
Static creator.- Parameters:
beanStore
- The bean store to use for creating beans.- Returns:
- A new builder for this object.
-
create
Static creator.- Returns:
- A new builder for this object.
-
add
Adds the specified thrown exception to this database.- Parameters:
e
- The exception to add.- Returns:
- This object.
-
getStats
Retrieves the stats for the specified thrown exception.- Parameters:
e
- The exception.- Returns:
- A clone of the stats, never
null .
-
getStats
Retrieves the stack trace information for the exception with the specified hash as calculated byhash(Throwable)
.- Parameters:
hash
- The hash of the exception.- Returns:
- A clone of the stack trace info, never
null .
-
getStats
Returns the list of all stack traces in this database.- Returns:
- The list of all stack traces in this database, cloned and sorted by count descending.
-
reset
Clears out the stack trace cache. -
hash
Calculates a 32-bit hash for the specified throwable based on the stack trace generated bycreateStackTrace(Throwable)
.Subclasses can override this method to provide their own implementation.
- Parameters:
t
- The throwable to calculate the stack trace on.- Returns:
- A calculated hash.
-
createStackTrace
Converts the stack trace for the specified throwable into a simple list of strings.The stack trace elements for the throwable are sent through
normalize(StackTraceElement)
to convert them to simple strings.- Parameters:
t
- The throwable to create the stack trace for.- Returns:
- A modifiable list of strings.
-
include
Returnstrue if the specified stack trace element should be included increateStackTrace(Throwable)
.- Parameters:
e
- The stack trace element.- Returns:
true if the specified stack trace element should be included increateStackTrace(Throwable)
.
-
normalize
Converts the specified stack trace element into a normalized string.The default implementation simply replaces
"\\$.*" with"..." which should take care of stuff like stack trace elements of lambda expressions.- Parameters:
e
- The stack trace element to convert.- Returns:
- The converted stack trace element.
-