-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression in Log4j 2.22.0 on Android because of changes to getThreadContextClassLoader() in LoaderUtil #2129
Comments
This reproduces apache/logging-log4j2#2129
In order to provide a minimal reproducer I have prepared a branch at https://github.com/centic9/poi-on-android/tree/log4j_2_22_0_minimal_reproducer which is a minimal Android Application, upgraded to latest SDK level 34, which still shows the issue when either tests are executed or the resulting Android application is started. |
Hi,
Yes I know the sad state of some differences between Java on Android and
JDK classes, however a lot of code can be used in both worlds currently.
It was working up to log4j 2.21.1, probably without any specific effort
being put into enabling it.
As log4j is used in many third party libraries, some of which try to
support running on Android, log4j is often dragged in as transitive
dependency. The regression in newer versions will likely make it harder for
all these libraries to provide support, maybe at sometime to a level which
forces them to use a different logging framework as there is no workaround
as far as I see.
As the breaking changes do not look absolutely necessary based on the
commit-message, you might want to consider doing a minimal revert so it can
again be used in this way?
Thanks... Dominik.
…On Thu, Dec 28, 2023 at 11:32 AM Joe ***@***.***> wrote:
@centic9 <https://github.com/centic9>
Does log4j2 support Android environments?
I think it's not.
Android SDK API 34 is compatible with OpenJDK some class,not all classes.
—
Reply to this email directly, view it on GitHub
<#2129 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEF3YT755SW25A2FAEXWDDYLVDDRAVCNFSM6AAAAABBDQA6ZGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZRGAZTONBTGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hi @centic9, Thank You for Your issue report.
That is the idea: we don't introduce breaking changes in 2.x. On the other hand we try to keep the two branches in sync, which helps backporting bug fixes from Thank you for your Android test. If you agree, we'll add it to our test suite, so that we prevent this kind of problems in the future. |
Thanks for the explanation. Feel free to take from the reproducer whatever is useful. |
We should probably just remove the |
No, Matt, we can't. Wildfly still supports Since we are struggling to support OSGi, JPMS, SecurityManager, Android and GraalVM and each of them has its own limitations, I would just propose to use Review-then-Commit on everything that concerns @centic9: Matt is working on removing |
No problem keeping support for |
This bug appears to be yet another sign that Android's version of Java 8 is non-standard. As the security manager stuff is only relevant when one is installed, I think this class just needs to skip the |
Hi, all Android SDK is not fully compatible with Openjdk. If you want Android to use log4j2, you need to remove the Openjdk API used in log4j2, which does not exist in Android SDK. |
This fixes issue #2129 where `AccessController::doPrivileged` is needlessly invoked when no `SecurityManager` is installed.
Description
When upgrading an Android Application which has a transitive dependency on Log4j from log4j-core 2.21.1 to 2.22.0, it fails with an exception because it seems the method AccessController.doPrivileged() with the required parameters is not available on Android, but calls to it are introduced in LoaderUtil now via commit 80de816
This prevents us from upgrading log4j when including any Java libraries which depend on log4j-core in an Android application.
Is it possible to not introduce these changes in the 2.x series? The commit-message sounds like this was sort of "let's backport some stuff from 3.x branches".
Configuration
Version: 2.22.0
Operating system: Android application with min SDK Level 26
JDK: Android
Logs
Reproduction
Can only be reproduced in Android applications using the Emulator.
There is a sample Android application "poi-on-android" which shows the issue:
The text was updated successfully, but these errors were encountered: