Skip to content

DiskRead and DiskWrite Violations in ChuckerCollector #737

@Alireza-Farahani

Description

@Alireza-Farahani

✍️ Describe the bug

I'm not even sure its Chucker problem or not, but Creating ChuckerInterceptor instance (done by Hilt in out app) results in both DiskReadViolation and DiskWriteViolation.

android.os.strictmode.DiskReadViolation: null
    at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1504)
    at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:251)
    at java.io.File.exists(File.java:815)
    at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:653)
    at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:644)
    at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:600)
    at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:809)
    at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:437)
    at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:179)
    at com.chuckerteam.chucker.api.RetentionManager.<init>(RetentionManager.kt:29)
    at com.chuckerteam.chucker.api.ChuckerCollector.<init>(ChuckerCollector.kt:28)
    at com.chuckerteam.chucker.api.ChuckerCollector.<init>(ChuckerCollector.kt:23)
    at com.chuckerteam.chucker.api.ChuckerInterceptor$Builder.build(ChuckerInterceptor.kt:366)
--------------------------
android.os.strictmode.DiskWriteViolation: null
    at android.os.StrictMode$AndroidBlockGuardPolicy.onWriteToDisk(StrictMode.java:1460)
    at java.io.UnixFileSystem.delete(UnixFileSystem.java:294)
    at java.io.File.delete(File.java:1037)
    at com.chuckerteam.chucker.internal.data.room.ChuckerDatabase$Companion.create(ChuckerDatabase.kt:22)
    at com.chuckerteam.chucker.internal.data.repository.RepositoryProvider.initialize(RepositoryProvider.kt:34)
    at com.chuckerteam.chucker.api.ChuckerCollector.<init>(ChuckerCollector.kt:32)
    at com.chuckerteam.chucker.api.ChuckerCollector.<init>(ChuckerCollector.kt:23)
    at com.chuckerteam.chucker.api.ChuckerInterceptor$Builder.build(ChuckerInterceptor.kt:366)

💣 Steps to reproduce

StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
    .detectDiskReads()
    .detectDiskWrites()
    .penalty<whatever>
    .build()
)

🔧 Expected behavior

Getting no violation

📷 Screenshots

📱 Tech info

  • Device: Pixel 2
  • OS: Android 11
  • Chucker version: 3.5.2

📄 Additional context

Actually I traced those two violations and one is a simple File delete and the other a new SharedPref and I know it's not much an issue, performance wise.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions