A lot of my users are facing a NullPointerException issue while instantiating content descriptor.
Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.content.UriMatcher.mText' on a null object reference
at android.content.UriMatcher.addURI(UriMatcher.java:186)
at com.getsuperapp.chat.db.ContentDescriptor.getUriMatcher(SourceFile:25)
at com.getsuperapp.chat.db.DatabaseProvider.query(SourceFile:33)
at android.content.ContentProvider.query(ContentProvider.java:1017)
at android.content.ContentProvider$Transport.query(ContentProvider.java:238)
at android.content.ContentResolver.query(ContentResolver.java:497)
at android.content.ContentResolver.query(ContentResolver.java:439)
The set of devices and environment can be found here.
The ContentDescriptor file is
/**
* A few constants from other classes used in the file
*
* from UserTable.java
* public static final String PATH = "user_table";
* public static final int PATH_TOKEN = 10;
*/
public class ContentDescriptor {
private static UriMatcher URI_MATCHER = null;
private static Uri BASE_URI = null;
public static UriMatcher getUriMatcher(Context appContext) {
String AUTHORITY = appContext.getPackageName() + ".quickblox";
if (URI_MATCHER == null) {
URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
//The line below is throwing the exception.
URI_MATCHER.addURI(AUTHORITY, UserTable.PATH, UserTable.PATH_TOKEN);
URI_MATCHER.addURI(AUTHORITY, DialogTable.PATH, DialogTable.PATH_TOKEN);
URI_MATCHER.addURI(AUTHORITY, MessageTable.PATH, MessageTable.PATH_TOKEN);
URI_MATCHER.addURI(AUTHORITY, ChatInfoTable.PATH, ChatInfoTable.PATH_TOKEN);
}
return URI_MATCHER;
}
public static Uri getBaseUri(Context appContext) {
String AUTHORITY = appContext.getPackageName() + ".quickblox";
if (BASE_URI == null) {
BASE_URI = Uri.parse("content://" + AUTHORITY);
}
return BASE_URI;
}
}
Let me know if you need any further information. Can anyone provide me some visibility into this. I'm unable to reproduce the crash at my end.
EDIT
Guys stop brushing this into any other NPE category without reading. Its running on a lot of devices without trouble. The initialisation parameters are constants. The line on which its crashing is commented in the code too.