mikifus / padland

Padland is a tool to manage, share, remember and read collaborative documents based on the Etherpad technology in Android.
Apache License 2.0
62 stars 15 forks source link

The application still has some bugs #54

Closed AssassinRain closed 4 years ago

AssassinRain commented 4 years ago

Hello. I noticed some crashes in logs. The corresponding commit version of code is 65e551e, and application version is 1.5.

1.com.mikifus.padland.PadViewActivity

The exception trace is: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mikifus.padland/com.mikifus.padland.PadViewActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.mikifus.padland.Models.Pad.g()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6944) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.mikifus.padland.Models.Pad.g()' on a null object reference at com.mikifus.padland.PadViewActivity.d(SourceFile:5) at com.mikifus.padland.PadViewActivity.k(SourceFile:1) at com.mikifus.padland.PadViewActivity.n(SourceFile:1) at com.mikifus.padland.PadViewActivity.onCreate(SourceFile:2) at android.app.Activity.performCreate(Activity.java:7183) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)

The command to trigger it is: adb shell am start -n com.mikifus.padland/com.mikifus.padland.PadViewActivity

Because all these activities are exported ones, i.e., be exposed to outside, they may receive unfriendly commands and then lead to app crash. After investigation, we found that the missing of null checkers causes those crashes. Please help to confirm whether they are true bugs. We believe that fixing these bugs will further improve the robustness of this app.

mikifus commented 4 years ago

Hi,

There are many things to unfold here:

  1. The latest APK release in this repo does not contain that last change. Only the Google Play Store version does, so Google stops complaining. Try again by compiling from source.
  2. The exported feature made sense at the beginning and would work but nowadays integration is better using other methods, so it should be removed.
  3. The adb call is not correct usage of the app, but in any case it should work if you pass a parameter (a pad url).

Thanks for your interest and implication.

AssassinRain commented 4 years ago

Thanks for your kindly reply. After compile the latest version into an apk and retest, we find that the same crash still can be triggered. Besides, we also find two new bugs. The detailed information are as follows:

1.com.mikifus.padland.PadViewActivity

The exception trace is: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mikifus.padland/com.mikifus.padland.PadViewActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.mikifus.padland.Models.Pad.getUrl()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6944) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.mikifus.padland.Models.Pad.getUrl()' on a null object reference at com.mikifus.padland.PadViewActivity._getPadId(PadViewActivity.java:311) at com.mikifus.padland.PadViewActivity._getPadData(PadViewActivity.java:251) at com.mikifus.padland.PadViewActivity._makePadUrl(PadViewActivity.java:218) at com.mikifus.padland.PadViewActivity.onCreate(PadViewActivity.java:118) at android.app.Activity.performCreate(Activity.java:7183) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)

The command to trigger it is: adb shell am start -n com.mikifus.padland/com.mikifus.padland.PadViewActivity

2.com.mikifus.padland.PadViewActivity

The exception trace is: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mikifus.padland/com.mikifus.padland.PadViewActivity}: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6944) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1975) at com.mikifus.padland.PadViewActivity.makePadData(PadViewActivity.java:641) at com.mikifus.padland.PadViewActivity._getPadDataFromIntent(PadViewActivity.java:291) at com.mikifus.padland.PadViewActivity._getPadId(PadViewActivity.java:310) at com.mikifus.padland.PadViewActivity._getPadData(PadViewActivity.java:251) at com.mikifus.padland.PadViewActivity._makePadUrl(PadViewActivity.java:218) at com.mikifus.padland.PadViewActivity.onCreate(PadViewActivity.java:118) at android.app.Activity.performCreate(Activity.java:7183) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)

The command to trigger it is: adb shell am start -n com.mikifus.padland/com.mikifus.padland.PadViewActivity -a android.intent.action.VIEW

3.com.mikifus.padland.PadListActivity

The exception trace is: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mikifus.padland/com.mikifus.padland.PadListActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6944) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference at com.mikifus.padland.PadListActivity.i(SourceFile:3) at com.mikifus.padland.PadListActivity.onCreate(SourceFile:2) at android.app.Activity.performCreate(Activity.java:7183) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)

And there are the parameters of our intent: action: null;; category: null;; data: null;; type: null;; extra-data: String->android.intent.extra.TEXT->abcde,Extras->ExtrasObj->ExtrasObj,(,long->focus_pad->0,),String->action->abcde

mikifus commented 4 years ago

Hi,

Thanks for the contribution and patience. I didn't have time to check it but I'm aware of this issue.