java.lang.NullPointerException: Attempt to invoke interface method 'java.io.InputStream org.apache.http.HttpEntity.getContent()' on a null object reference

Appcelerator JIRA | Wilson Luu | 1 year ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    *Details:* Updating a record with Arrow Android SDK throws {{java.lang.NullPointerException}} in the {{onError}} callback. *Notes:* * To workaround this issue, you will need to replace lines 115 - 122 in {{API.java}} with the following: {code} JSONObject json = null; if(entity != null) { InputStream content = entity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(content)); StringBuilder builder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { builder.append(line); } if(builder.length() != 0) { json = new JSONObject(builder.toString()); } } {code} * The workaround above incorporates the workaround from API-1196. *Steps to reproduce:* # Download and unzip MonkeyArr.zip; this is a *Android Studio* project # Open the project in Android Studio # Next, create an Arrow project and run the Arrow project locally # In the Android project, open {{MainActivity.java}} and change the following: ## Replace the API key in {{MonkeySdk.setAuthorization("71YFaz201s55+Mmvzh5G62sqo3tUwwbS")}}. ## If you are planning to launch against the stock emulator, replace {{10.0.3.2}} with {{10.0.2.2}}; otherwise, leave as-is. # Launch Android app to emualtor or Genymotion emulator # Press the {{Test}} button *Actual:* {{java.lang.NullPointerException}} is thrown to the {{onError}} callback: {code} 02-10 19:31:16.350 24744-24926/com.appc.monkeyarr I/monkeyarr: #1 CREATE and READ test. 02-10 19:31:16.350 24744-24926/com.appc.monkeyarr I/monkeyarr: #Finished test #1. 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr I/monkeyarr: onError 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: java.lang.NullPointerException: Attempt to invoke interface method 'java.io.InputStream org.apache.http.HttpEntity.getContent()' on a null object reference 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at com.monkeysdk.API.execute(API.java:115) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at com.monkeysdk.Testuser$9.doInBackground(Testuser.java:430) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at com.monkeysdk.Testuser$9.doInBackground(Testuser.java:421) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.lang.Thread.run(Thread.java:818) {code} *Expected:* {{java.lang.NullPointerException}} should not be thrown when updating a record.

    Appcelerator JIRA | 1 year ago | Wilson Luu
    java.lang.NullPointerException: Attempt to invoke interface method 'java.io.InputStream org.apache.http.HttpEntity.getContent()' on a null object reference
  2. 0

    *Details:* Updating a record with Arrow Android SDK throws {{java.lang.NullPointerException}} in the {{onError}} callback. *Notes:* * To workaround this issue, you will need to replace lines 115 - 122 in {{API.java}} with the following: {code} JSONObject json = null; if(entity != null) { InputStream content = entity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(content)); StringBuilder builder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { builder.append(line); } if(builder.length() != 0) { json = new JSONObject(builder.toString()); } } {code} * The workaround above incorporates the workaround from API-1196. *Steps to reproduce:* # Download and unzip MonkeyArr.zip; this is a *Android Studio* project # Open the project in Android Studio # Next, create an Arrow project and run the Arrow project locally # In the Android project, open {{MainActivity.java}} and change the following: ## Replace the API key in {{MonkeySdk.setAuthorization("71YFaz201s55+Mmvzh5G62sqo3tUwwbS")}}. ## If you are planning to launch against the stock emulator, replace {{10.0.3.2}} with {{10.0.2.2}}; otherwise, leave as-is. # Launch Android app to emualtor or Genymotion emulator # Press the {{Test}} button *Actual:* {{java.lang.NullPointerException}} is thrown to the {{onError}} callback: {code} 02-10 19:31:16.350 24744-24926/com.appc.monkeyarr I/monkeyarr: #1 CREATE and READ test. 02-10 19:31:16.350 24744-24926/com.appc.monkeyarr I/monkeyarr: #Finished test #1. 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr I/monkeyarr: onError 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: java.lang.NullPointerException: Attempt to invoke interface method 'java.io.InputStream org.apache.http.HttpEntity.getContent()' on a null object reference 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at com.monkeysdk.API.execute(API.java:115) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at com.monkeysdk.Testuser$9.doInBackground(Testuser.java:430) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at com.monkeysdk.Testuser$9.doInBackground(Testuser.java:421) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 02-10 19:31:16.610 24744-24927/com.appc.monkeyarr W/System.err: at java.lang.Thread.run(Thread.java:818) {code} *Expected:* {{java.lang.NullPointerException}} should not be thrown when updating a record.

    Appcelerator JIRA | 1 year ago | Wilson Luu
    java.lang.NullPointerException: Attempt to invoke interface method 'java.io.InputStream org.apache.http.HttpEntity.getContent()' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke interface method 'java.io.InputStream org.apache.http.HttpEntity.getContent()' on a null object reference

      at com.monkeysdk.API.execute()
    2. com.monkeysdk
      Testuser$9.doInBackground
      1. com.monkeysdk.API.execute(API.java:115)
      2. com.monkeysdk.Testuser$9.doInBackground(Testuser.java:430)
      3. com.monkeysdk.Testuser$9.doInBackground(Testuser.java:421)
      3 frames
    3. Android Platform
      AsyncTask$2.call
      1. android.os.AsyncTask$2.call(AsyncTask.java:288)
      1 frame
    4. Java RT
      FutureTask.run
      1. java.util.concurrent.FutureTask.run(FutureTask.java:237)
      1 frame
    5. Android Platform
      AsyncTask$SerialExecutor$1.run
      1. android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
      1 frame
    6. Java RT
      Thread.run
      1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
      3. java.lang.Thread.run(Thread.java:818)
      3 frames