Skip to content

Potential NPE during AndroidCacheFileFactory initialization #414

@koral--

Description

@koral--

✍️ Describe the bug

The current code at: https://github.com/ChuckerTeam/chucker/blob/develop/library/src/main/java/com/chuckerteam/chucker/internal/support/AndroidCacheFileFactory.kt#L17 assumes that context.cacheDir returns non-null value. However, on Android older than 7.0 this method can return null: http://androidxref.com/6.0.0_r1/xref/frameworks/base/core/java/android/app/ContextImpl.java#425

💣 Steps to reproduce

  1. Cause cache dir to be not creatable eg. create regular file with the same name beforehand or fill entire disk space.
  2. Invoke ChuckerInterceptor constructor.

🔧 Expected behavior

Not sure what is that cache used for. If it is mandatory, NPE could be wrapped by IOException.

📷 Screenshots

N/A

📱 Tech info

  • OS: < 7.0
  • Chucker version: at least one which is built from commit 392a63b or newer.

📄 Additional context

I haven't encountered this issue at runtime. Just realized that it may happen during #413 investigation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions