[
https://issues.apache.org/jira/browse/CB-6378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13990629#comment-13990629
]
Andrew Grieve commented on CB-6378:
-----------------------------------
>From the discussion - fix is to call disconnect() in stead of close().
> OkHttp 1.5 NPE when closing stream
> ----------------------------------
>
> Key: CB-6378
> URL: https://issues.apache.org/jira/browse/CB-6378
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android
> Affects Versions: 2.9.0
> Environment: Android
> Reporter: Andrew Shu
> Priority: Minor
>
> Cordova 2.9.1. Using FileTransfer plugin.
> When upgrading the project's OkHttp version to 1.5, it frequently crashes due
> to a broken assumption made by Cordova that HttpURLConnection is thread safe.
> On Android it is explicitly not thread safe:
> http://developer.android.com/reference/java/net/HttpURLConnection.html
> Short discussion: https://github.com/square/okhttp/issues/655
> Stack trace:
> java.lang.NullPointerException
> at com.squareup.okhttp.internal.okio.OkBuffer.write(OkBuffer.java:519)
> at com.squareup.okhttp.internal.okio.OkBuffer.read(OkBuffer.java:555)
> at
> com.squareup.okhttp.internal.okio.RealBufferedSource.read(RealBufferedSource.java:53)
> at
> com.squareup.okhttp.internal.http.HttpConnection$FixedLengthSource.read(HttpConnection.java:413)
> at com.squareup.okhttp.internal.Util.skipAll(Util.java:234)
> at
> com.squareup.okhttp.internal.http.HttpConnection.discard(HttpConnection.java:183)
> at
> com.squareup.okhttp.internal.http.HttpConnection$FixedLengthSource.close(HttpConnection.java:435)
> at
> com.squareup.okhttp.internal.okio.RealBufferedSource.close(RealBufferedSource.java:206)
> at
> com.squareup.okhttp.internal.okio.RealBufferedSource$1.close(RealBufferedSource.java:181)
> at java.io.FilterInputStream.close(FilterInputStream.java:64)
> at org.apache.cordova.FileTransfer.safeClose(FileTransfer.java:515)
> at org.apache.cordova.FileTransfer.access$300(FileTransfer.java:64)
> at org.apache.cordova.FileTransfer$5.run(FileTransfer.java:864)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
> at java.lang.Thread.run(Thread.java:841)
--
This message was sent by Atlassian JIRA
(v6.2#6252)