Uploaded image for project: 'Couchbase Lite'
  1. Couchbase Lite
  2. CBL-89

Calling Replicator#stop() on a replicator that hasn't started throws NPE

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.0, 2.1.0, 2.1.5, 2.1.2, 2.0.0, 2.0.2
    • 2.6.0
    • Java-Android
    • Security Level: Public
    • None

    Description

      Following on from CBL-88, the idea for a quick workaround of just trying to stop the replicator anyway also fails as we hit a different NPE in checking the activity level (potentially the same root cause though - that the status is null)

      Basic repro:

      public class MainActivity extends AppCompatActivity {
       
          Database db;
          Replicator r;
          URI u;
       
          @Override
          protected void onCreate (Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
       
              DatabaseConfiguration dbc = new DatabaseConfiguration(this);
              try {
                  db = new Database("test", dbc);
              } catch (CouchbaseLiteException e) {
                  e.printStackTrace();
              }
       
              try {
                  u = new URI("ws://localhost");
              } catch (URISyntaxException e) {
                  e.printStackTrace();
              }
              ReplicatorConfiguration rpc = new ReplicatorConfiguration(db, new URLEndpoint(u));
       
              r = new Replicator(rpc);
              try {
                  r.getStatus();
              } catch (NullPointerException e) {
                  e.printStackTrace();// CBL-88
              }
              r.stop();
          }
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          2019-06-13 17:30:07.774 27844-27844/? D/AndroidRuntime: Shutting down VM
              
              
              --------- beginning of crash
          2019-06-13 17:30:07.776 27844-27844/? E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.couchbase.jflath.basicreplicator, PID: 27844
              java.lang.RuntimeException: Unable to start activity ComponentInfo{com.couchbase.jflath.basicreplicator/com.couchbase.jflath.basicreplicator.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.couchbase.litecore.C4ReplicatorStatus.getActivityLevel()' on a null object reference
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2951)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
                  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
                  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
                  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
                  at android.os.Handler.dispatchMessage(Handler.java:106)
                  at android.os.Looper.loop(Looper.java:193)
                  at android.app.ActivityThread.main(ActivityThread.java:6718)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
               Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.couchbase.litecore.C4ReplicatorStatus.getActivityLevel()' on a null object reference
                  at com.couchbase.lite.AbstractReplicator.stop(AbstractReplicator.java:364)
                  at com.couchbase.jflath.basicreplicator.MainActivity.onCreate(MainActivity.java:66)
                  at android.app.Activity.performCreate(Activity.java:7144)
                  at android.app.Activity.performCreate(Activity.java:7135)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086) 
                  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
                  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
                  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816) 
                  at android.os.Handler.dispatchMessage(Handler.java:106) 
                  at android.os.Looper.loop(Looper.java:193) 
                  at android.app.ActivityThread.main(ActivityThread.java:6718) 
                  at java.lang.reflect.Method.invoke(Native Method) 
                  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
          

          James Flather James Flather added a comment - 2019-06-13 17:30:07.774 27844-27844/? D/AndroidRuntime: Shutting down VM --------- beginning of crash 2019-06-13 17:30:07.776 27844-27844/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.couchbase.jflath.basicreplicator, PID: 27844 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.couchbase.jflath.basicreplicator/com.couchbase.jflath.basicreplicator.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.couchbase.litecore.C4ReplicatorStatus.getActivityLevel()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2951) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6718) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.couchbase.litecore.C4ReplicatorStatus.getActivityLevel()' on a null object reference at com.couchbase.lite.AbstractReplicator.stop(AbstractReplicator.java:364) at com.couchbase.jflath.basicreplicator.MainActivity.onCreate(MainActivity.java:66) at android.app.Activity.performCreate(Activity.java:7144) at android.app.Activity.performCreate(Activity.java:7135) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:6718)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
          blake.meike Blake Meike added a comment -

          fixed in couchbase-lite-android 63b34f3d5157749f751da5f5c57ec4e35393b9dd

          blake.meike Blake Meike added a comment - fixed in couchbase-lite-android 63b34f3d5157749f751da5f5c57ec4e35393b9dd

          Reopened to update the versions - can be closed once we flesh out the project with the version numbers

          James Flather James Flather added a comment - Reopened to update the versions - can be closed once we flesh out the project with the version numbers

          James Flather, what version are you looking for?

          daniel.petersen Daniel Petersen added a comment - James Flather , what version are you looking for?

          Daniel Petersen The Affects Version should ideally list every affected version. In this case, that would be:
          2.0.0 2.0.2 2.1.0 2.1.2 2.1.5 2.5.0

          James Flather James Flather added a comment - Daniel Petersen The Affects Version should ideally list every affected version. In this case, that would be: 2.0.0 2.0.2 2.1.0 2.1.2 2.1.5 2.5.0

          People

            The Lite The Lite
            James Flather James Flather
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty