NPE while invoking tinylog from an AIDL remote interface callback
See original GitHub issueMy code is throwing an exception for this constructor:
public ServiceLoader(final Class<? extends T> service, final Class<?>... argumentTypes) {
this.service = service;
this.argumentTypes = argumentTypes;
this.classLoader = Thread.currentThread().getContextClassLoader();
this.classes = loadClasses(classLoader, service);
}
01-13 12:08:03.272 3989-4000/loylap.poynt.gift E/JavaBinder: *** Uncaught remote exception! (Exceptions are not yet supported across processes.)
java.lang.ExceptionInInitializerError
at org.tinylog.provider.ProviderRegistry.getLoggingProvider(ProviderRegistry.java:53)
at org.tinylog.kotlin.Logger.<clinit>(Logger.kt:27)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Enumeration java.lang.ClassLoader.getResources(java.lang.String)' on a null object reference
at org.tinylog.configuration.ServiceLoader.loadClasses(ServiceLoader.java:128)
at org.tinylog.configuration.ServiceLoader.<init>(ServiceLoader.java:58)
at org.tinylog.provider.ProviderRegistry.loadLoggingProvider(ProviderRegistry.java:66)
at org.tinylog.provider.ProviderRegistry.<clinit>(ProviderRegistry.java:36)
at org.tinylog.provider.ProviderRegistry.getLoggingProvider(ProviderRegistry.java:53)
at org.tinylog.kotlin.Logger.<clinit>(Logger.kt:27)
I believe Thread.currentThread().getContextClassLoader();
is returning null in certain instances in my app. I don’t understand enough about Java or AIDLs to see what’s happening here, but suffice it to say calls to log functions (such as Logger.trace()
) are crashing when they are invoked from very specific interface call backs in my app which use AIDL and are on a background thread. Running Logger.trace on the main thread from within the interface callback fixes the issue, but I am worried now there could be places in my code I don’t make this fix, and also that I might be introducing other subtle issues I don’t know about, like this one.
This is probably an Android only problem, but would love to know what the cause is and how I might mitigate it. It’s super difficult for me to try and make a reproducible sample because I am seeing the error in an SDK dependency which uses TinyLog
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
I’ve tried it with a super simple AIDL / Service sample and can’t repro. So it must be something relatively specific. I will try and create a very simple project with nothing but the Service I am using. Versions are:
This closed issue has been locked automatically. However, please feel free to file a new issue.