Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-6378

OkHttp 1.5 NPE when closing stream

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.9.0
    • None
    • cordova-android
    • None
    • Android

    Description

      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)

      Attachments

        Issue Links

          Activity

            People

              agrieve Andrew Grieve
              talklittle Andrew Shu
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: