Support Topics Documentation Slack YouTube Blog

Atomic counter


(Fabio Na) #1

Hi guys, I’m messing around with my app, on purpouse I’ve setted wrong application id and/or wrong api key, no crash, except when I call atomic counter (no blocking api)

java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.Class java.lang.Object.getClass()’ on a null object reference
at com.backendless.atomic.AtomicCallback.handleResponse(AtomicCallback.java:45)
at com.backendless.async.message.AsyncMessage$ResponseHandler.handle(AsyncMessage.java:64)
at com.backendless.async.message.AsyncMessage.handleCallback(AsyncMessage.java:41)
at com.backendless.core.AndroidCarrier$1.handleMessage(AndroidCarrier.java:37)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)

same with blocking api, but it can be surrounded with try catch block.

I know it’s a nonsense with wrong id, but, give it a look


(Vladimir Yalovy) #2

Hello @fabio_na

I try reproduce your step, i send https://api.backendless.com/<wrong-application-id>/<REST-api-key>/counters/<counterName>/get/increment (https://backendless.com/docs/rest/ut_increment_by_1__return_previou.html) and i get error: Application with ID XXX does not exist.
Please write what kind of requests you fill out and what you get in return.


(Fabio Na) #3

My bad, I’ve setted android tag for this request but I’ve not specified the api used.

https://backendless.com/docs/android/ut_increment_by_1__return_current_android.html

 Backendless.Counters.incrementAndGet(counterName, new AsyncCallback<Integer>() {
        @Override
        public void handleResponse(Integer response) {
            Log.e(TAG, "handleResponse: " + counterName + ": " + response);
        }

        @Override
        public void handleFault(BackendlessFault fault) {
            Log.e(TAG, "handleFault: " + fault);
        }
    });

this is the faulty code.
In return I have

java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.Class java.lang.Object.getClass()’ on a null object reference

at com.backendless.atomic.AtomicCallback.handleResponse(AtomicCallback.java:45)
at com.backendless.async.message.AsyncMessage$ResponseHandler.handle(AsyncMessage.java:64)
at com.backendless.async.message.AsyncMessage.handleCallback(AsyncMessage.java:41)
at com.backendless.core.AndroidCarrier$1.handleMessage(AndroidCarrier.java:37)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)


(Vladimir Yalovy) #4

Yes, I managed to reproduce.
I created an internal ticket (BKNDLSS-18367). Progress fixes will be written in this topic.


(Mark Piller) #5

@fabio_na, I just wanted to make sure that with the correct application ID the functionality is working as expected. Please confirm.

Thanks,
Mark


(Fabio Na) #6

yeah, it works great!
I’m just testing, cause once in production I want to cover every possible error to avoid crash. I could have easily catched the “synchronous” version of this api with a try catch block.
I’m still using the free plan, the least I can do is report unexpected behaviors