Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StrictMode warning that InputStream is not closed #303

Closed
VladislavNikolaev opened this issue Aug 2, 2017 · 2 comments
Closed

StrictMode warning that InputStream is not closed #303

VladislavNikolaev opened this issue Aug 2, 2017 · 2 comments
Assignees
Labels
bug Acknowledged bug in Upload Service
Milestone

Comments

@VladislavNikolaev
Copy link

What did you expect?

No StrictMode warnings

What happened instead?

Strict mode warning about not closed input stream

Version info

  • Android Upload Service version: 3.2.5
  • HTTP stack: OkHttp

Steps to reproduce (if applicable):

Enable StrictMode:

public class MyApplication extends Application{
 @Override
    public void onCreate() {
        super.onCreate();
        if (BuildConfig.DEBUG) {
            enableStrictMode();
        }
    }

  private void enableStrictMode() {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                .detectAll()
                .penaltyLog()
                .penaltyDialog()
                .build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll()
                .penaltyLog()
                .build());
    }
}

LogCat output

StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
                                                                         java.lang.Throwable: Explicit termination method 'close' not called
                                                                             at dalvik.system.CloseGuard.open(CloseGuard.java:184)
                                                                             at java.io.FileInputStream.<init>(FileInputStream.java:78)
                                                                             at net.gotev.uploadservice.schemehandlers.FileSchemeHandler.getInputStream(FileSchemeHandler.java:32)
                                                                             at net.gotev.uploadservice.UploadFile.getStream(UploadFile.java:68)
                                                                             at net.gotev.uploadservice.BinaryUploadTask.onBodyReady(BinaryUploadTask.java:23)
                                                                             at net.gotev.uploadservice.okhttp.OkHttpStackConnection$1.writeTo(OkHttpStackConnection.java:107)

Additional info

close method should be called for InputStream

@gotev gotev added this to the 3.3.1 milestone Aug 2, 2017
@gotev gotev added the bug Acknowledged bug in Upload Service label Aug 2, 2017
@gotev gotev self-assigned this Aug 2, 2017
@gotev
Copy link
Owner

gotev commented Aug 2, 2017

Thanks for pointing this out! It should be fixed now and it will be released in 3.3.1

@gotev gotev closed this as completed Aug 2, 2017
@gotev
Copy link
Owner

gotev commented Aug 2, 2017

Released 3.3.1 with this fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Acknowledged bug in Upload Service
Projects
None yet
Development

No branches or pull requests

2 participants