Unverified Commit 7aab20a9 authored by sebright's avatar sebright Committed by GitHub
Browse files

Fix ClassCastException in opencensus-contrib-log-correlation-log4j2. (#1437)

Fixes #1436.

Log4j's SortedArrayStringMap can contain Object values, but
`SortedArrayStringMap.getValue` has signature `<V> V getValue(String key)` and
unsafely casts the Objects to type `V`.  When the OpenCensus ContextDataInjector
returned a SortedArrayStringMap, and then a Log4j ContextMapLookup looked up
values as Strings to insert them into log entries
(https://github.com/apache/logging-log4j2/blob/fa27894c13c3890e4ae545f6b6365ea2e159757c/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/ContextMapLookup.java#L58),
it resulted in a ClassCastException.

This commit fixes the ClassCastException by only inserting String values into
the Log4j SortedArrayStringMap.
parent 69360e98
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment