rparkins999 / CalendarTrigger

Android app to trigger actions on calendar events
GNU General Public License v3.0
13 stars 6 forks source link

Calendar trigger app gets crashed. #7

Closed Sammaz2 closed 6 years ago

Sammaz2 commented 6 years ago

Actual behavior

I opened the calendar trigger opensource android app. After that I clicked on New event class option. After that I created a new event class and after that I clicked on Event end definition for class ..... Then I filled the minutes blanks, after that I filled the steps blank. And then meters blank. Then I clicked on the back button. Unfortunately the app crashed suddenly.

How to reproduce

https://youtu.be/NwMLQExfNlo

tobias-g1 commented 6 years ago

Replicated on Android 7.0

This issue seems to only occur when large numbers are entered.

05-26 19:26:31.932 8261-8261/uk.co.yahoo.p1rpp.calendartrigger E/AndroidRuntime: FATAL EXCEPTION: main
    Process: uk.co.yahoo.p1rpp.calendartrigger, PID: 8261
    java.lang.NumberFormatException: For input string: "323213123123123123"
        at java.lang.Integer.parseInt(Integer.java:524)
        at java.lang.Integer.<init>(Integer.java:706)
        at uk.co.yahoo.p1rpp.calendartrigger.activites.h.onPause(Unknown Source)
        at android.app.Fragment.performPause(Fragment.java:2530)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1043)
        at android.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1276)
        at android.app.BackStackRecord.popFromBackStack(BackStackRecord.java:1691)
        at android.app.FragmentManagerImpl.popBackStackState(FragmentManager.java:1637)
        at android.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:579)
        at android.app.Activity.onBackPressed(Activity.java:2751)
        at android.app.Activity.onKeyUp(Activity.java:2725)
        at android.view.KeyEvent.dispatch(KeyEvent.java:2700)
        at android.app.Activity.dispatchKeyEvent(Activity.java:3026)
        at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:317)
        at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4327)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4298)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3849)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3902)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3868)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3995)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3876)
        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4052)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3849)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3902)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3868)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3876)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3849)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3902)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3868)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4028)
        at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4189)
        at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2365)
        at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1961)
        at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1952)
        at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2342)
        at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:323)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:6077)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
rparkins999 commented 6 years ago

Well 323213123123123123 isn't a plausible value for minutes (longer than the age of the Universe) or steps or metres (well beyond the Solar System). Bad input shouldn't crash the program, but I don't think that this is a very serious bug since the input fields do only allow numbers, and any number that is a plausible value is handled. I agree that I ought either to catch NumberFormatException in case you input a number too big to fit into a java integer or use an InputFilter.LengthFilter to prevent you from inputting a big number at all. I think I prefer the length filter because it avoids having to pop up an error message if I catch the exception. In general it's better to prevent the user from doing bad things than generate an error if (s)he does. I'll fix it (for all number input fields) in the next version.

tobias-g1 commented 6 years ago

I agree I don't believe it will affect the large majority of the application users because it's out of normal use, but thought I should provide some extra detail where I could. Would be better to prevent the issue, definitely agree.

rparkins999 commented 6 years ago

Fixed in release 2.2 on github, not in fdroid yet.

rparkins999 commented 6 years ago

Release 2.2 which fixes this is now available in both github and fdroid, so closing issue.