This repository has been archived by the owner on Dec 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 202
ClassCastException with Log4j log correlation #1436
Comments
sebright
added a commit
to sebright/opencensus-java
that referenced
this issue
Sep 15, 2018
Fixes census-instrumentation#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.
sebright
added a commit
that referenced
this issue
Sep 17, 2018
…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.
sebright
added a commit
to sebright/opencensus-java
that referenced
this issue
Sep 18, 2018
…ensus-instrumentation#1437) Fixes census-instrumentation#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. (cherry picked from commit 7aab20a)
This was referenced Sep 18, 2018
Closed
sebright
added a commit
to sebright/opencensus-experiments
that referenced
this issue
Sep 18, 2018
opencensus-java 0.16.1 has a fix for census-instrumentation/opencensus-java#1436, which affected the Log4j log correlation demo.
sebright
added a commit
to census-ecosystem/opencensus-experiments
that referenced
this issue
Sep 18, 2018
opencensus-java 0.16.1 has a fix for census-instrumentation/opencensus-java#1436, which affected the Log4j log correlation demo.
rghetia
pushed a commit
to census-ecosystem/opencensus-experiments
that referenced
this issue
Dec 12, 2018
opencensus-java 0.16.1 has a fix for census-instrumentation/opencensus-java#1436, which affected the Log4j log correlation demo.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I got a ClassCastException with opencensus-contrib-log-correlation-log4j2 when using it with a Log4j JsonLayout:
I think the issue is that the OpenCensus ContextDataInjector adds Object values to the Log4j context, but Log4j doesn't call
String.valueOf
on those Objects on all code paths.The text was updated successfully, but these errors were encountered: