Our team is trying to use the Elasticsearch Java High Level REST Client 7.7.1 on an Android device. So far we've only been indexing data, not querying, and that code has been functional. But when trying to simply instantiate a
SearchSourceBuilder object, the following error occurs:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.security.CodeSource java.security.ProtectionDomain.getCodeSource()' on a null object reference at org.elasticsearch.Build.getElasticsearchCodeSourceLocation(Build.java:194) at org.elasticsearch.Build.<clinit>(Build.java:137) at org.elasticsearch.common.logging.DeprecationLogger.<clinit>(DeprecationLogger.java:154) at org.elasticsearch.search.builder.SearchSourceBuilder.<clinit>(SearchSourceBuilder.java:83)
The specific line of code which causes this
NullPointerException is the following (
final CodeSource codeSource = Build.class.getProtectionDomain().getCodeSource();
Apparently, per this StackOverflow answer, the method
getProtectionDomain() "is not implemented in Android's version of Java."
Build.class.getProtectionDomain() thus returns null, hence the
This would indicate that any classes which use the
DeprecationLogger, such as the critically important
SearchSourceBuilder, will not function on Android. This is an issue with the Java REST Client.