Skip to content

Possible bug: NullPointerException right on the call to the CTOR of ContentInfoUtil #93

Description

@AndroidDeveloperLB

I use this library on one of my Android apps, with this dependency:

implementation("com.j256.simplemagic:simplemagic:1.17")

I recently got a crash that I'm not sure what causes it.

The code that it crashes on is very simple, which works fine on my case, and it crashes right on the CTOR usage:

val util = ContentInfoUtil()
...

The relevant stacktrace:

Fatal Exception: java.lang.ExceptionInInitializerError:
       at com.j256.simplemagic.logger.LoggerFactory.findLogBackendFactory(LoggerFactory.java:108)
       at com.j256.simplemagic.logger.LoggerFactory.getLogger(LoggerFactory.java:43)
       at com.j256.simplemagic.logger.LoggerFactory.getLogger(LoggerFactory.java:35)
       at com.j256.simplemagic.entries.MagicEntries.<clinit>(MagicEntries.java:22)
       at com.j256.simplemagic.ContentInfoUtil.readEntries(ContentInfoUtil.java:380)
       at com.j256.simplemagic.ContentInfoUtil.readEntriesFromResource(ContentInfoUtil.java:372)
       at com.j256.simplemagic.ContentInfoUtil.<init>(ContentInfoUtil.java:80)
       at com.j256.simplemagic.ContentInfoUtil.<init>(ContentInfoUtil.java:65)
...

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Package.getName()' on a null object reference
       at com.j256.simplemagic.logger.LogBackendType.<init>(LogBackendType.java:69)
       at com.j256.simplemagic.logger.LogBackendType.<clinit>(LogBackendType.java:19)
       at com.j256.simplemagic.logger.LoggerFactory.findLogBackendFactory(LoggerFactory.java:108)
       at com.j256.simplemagic.logger.LoggerFactory.getLogger(LoggerFactory.java:43)
       at com.j256.simplemagic.logger.LoggerFactory.getLogger(LoggerFactory.java:35)
       at com.j256.simplemagic.entries.MagicEntries.<clinit>(MagicEntries.java:22)
       at com.j256.simplemagic.ContentInfoUtil.readEntries(ContentInfoUtil.java:380)
       at com.j256.simplemagic.ContentInfoUtil.readEntriesFromResource(ContentInfoUtil.java:372)
       at com.j256.simplemagic.ContentInfoUtil.<init>(ContentInfoUtil.java:80)
       at com.j256.simplemagic.ContentInfoUtil.<init>(ContentInfoUtil.java:65)
...

It doesn't seem like the app was modified, but it's just one crash for a single user. Then again, I wouldn't call the app popular, and reaching this part of the app might be rare.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions