You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow disabling the optimization for filling the stack traces
Description
Utility PrivateSecurityManagerStackTraceUtil offers an optimized way to fill the stack traces. For this it uses SecurityManager.getClassContext() which is faster.
Unfortunately, it is not always possible. On Android security managers are not used. Though class SecurityManager is present in the classpath, it contains just stubs; hence the array returned from getClassContext() is always null. This results in an NPE when Log4J tries to use it to fill the stack trace.
Fortunately, Log4J library will first check isEnabled() before using this optimization.
Configuration
Version: 2.24.3
Operating system: Android
JDK: not relevant
Logs
Not relevant
Reproduction
Just log an arbitrary exception:
log.warn("test", newException());
Solution
For now, the proposed remedy is to allow the developer on Android to explicitly disable this optimization.
A bigger problem is coming later, as java.lang.SecurityManager is deprecated and marked for removal. Once it is removed, the PrivateSecurityManagerStackTraceUtil (who internally extends SecurityManager) will start failing to load on Android. That will require a better mechanism to exclude this optimization from the execution path.
PS: In the website for the upcoming 2.25.0 release we added a FAQ entry about Android. Can you add a reference to your Log4j API implementation and explain how it differs from com.celeral:log4j2-android?
Allow disabling the optimization for filling the stack traces
Description
Utility
PrivateSecurityManagerStackTraceUtil
offers an optimized way to fill the stack traces. For this it usesSecurityManager.getClassContext()
which is faster.Unfortunately, it is not always possible. On Android security managers are not used. Though class
SecurityManager
is present in the classpath, it contains just stubs; hence the array returned fromgetClassContext()
is always null. This results in an NPE when Log4J tries to use it to fill the stack trace.Fortunately, Log4J library will first check
isEnabled()
before using this optimization.Configuration
Version: 2.24.3
Operating system: Android
JDK: not relevant
Logs
Not relevant
Reproduction
Just log an arbitrary exception:
Solution
For now, the proposed remedy is to allow the developer on Android to explicitly disable this optimization.
A bigger problem is coming later, as
java.lang.SecurityManager
is deprecated and marked for removal. Once it is removed, thePrivateSecurityManagerStackTraceUtil
(who internally extendsSecurityManager
) will start failing to load on Android. That will require a better mechanism to exclude this optimization from the execution path.Action points
SecurityManager
is missing in runtimeThe text was updated successfully, but these errors were encountered: