Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem when retreiving from Parse Cloud function #159

Closed
Natcha119 opened this issue Sep 30, 2015 · 10 comments
Closed

Problem when retreiving from Parse Cloud function #159

Natcha119 opened this issue Sep 30, 2015 · 10 comments

Comments

@Natcha119
Copy link

Hello,
I got some problem about using function callFunctionInBackground from Parse Cloud which always return NullPointerException but I can call the same Cloud function and it's work well in IOS.

My client code

ParseCloud.callFunctionInBackground("feeds", params, new FunctionCallback<Object>() {
            public void done(Object object, ParseException e) {
                if (e == null) {
                    Log.d("OK","connect to feeds function!");
                } else {
                    Log.d("ERROR", "fail!");
                }
            }
        });

And here is Cloud code

Parse.Cloud.define("feeds", function(req, res) {
    var Article = Parse.Object.extend('Article');
    var feed = {};
    var query = new Parse.Query(Article);

    query.descending('createdAt');
    query.include('user');
    query.limit(5);
    query.equalTo('postType', 'standard');
    query.find().then(function(results) {
        feed.other = results;

        query.limit(3);
        query.equalTo('postType', 'quote');
        query.find().then(function(results) {
            feed.quote = results;

            query.descending('likes');
            query.limit(2);
            query.equalTo('postType', 'standard');
            query.find().then(function(results) {
                feed.trendy = results;
                res.success(feed);
            });
        });
    },
    function() {
        res.error({
            message : 'Failed loading feed'
        });
    });
});

The log

 09-30 14:36:07.893      748-748/com.example.faang.testrequest W/System.err﹕ com.parse.ParseException: java.lang.NullPointerException
09-30 14:36:07.903      748-748/com.example.faang.testrequest W/System.err﹕ at com.parse.ParseTaskUtils$2$1.run(ParseTaskUtils.java:113)
09-30 14:36:07.903      748-748/com.example.faang.testrequest W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:615)
09-30 14:36:07.903      748-748/com.example.faang.testrequest W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:92)
09-30 14:36:07.913      748-748/com.example.faang.testrequest W/System.err﹕ at android.os.Looper.loop(Looper.java:137)
09-30 14:36:07.913      748-748/com.example.faang.testrequest W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:4745)
09-30 14:36:07.913      748-748/com.example.faang.testrequest W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
09-30 14:36:07.913      748-748/com.example.faang.testrequest W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:511)
09-30 14:36:07.923      748-748/com.example.faang.testrequest W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-30 14:36:07.933      748-748/com.example.faang.testrequest W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-30 14:36:07.933      748-748/com.example.faang.testrequest W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
09-30 14:36:07.933      748-748/com.example.faang.testrequest W/System.err﹕ Caused by: java.lang.NullPointerException
09-30 14:36:07.953      748-748/com.example.faang.testrequest W/System.err﹕ at com.parse.ParseObject$State$Init.updatedAt(ParseObject.java:143)
09-30 14:36:07.953      748-748/com.example.faang.testrequest W/System.err﹕ at com.parse.ParseObject.mergeFromServer(ParseObject.java:990)
09-30 14:36:07.973      748-748/com.example.faang.testrequest W/System.err﹕ at com.parse.ParseObject.fromJSON(ParseObject.java:686)
09-30 14:36:07.973      748-748/com.example.faang.testrequest W/System.err﹕ at com.parse.ParseDecoder.decode(ParseDecoder.java:125)
09-30 14:36:07.973      748-748/com.example.faang.testrequest W/System.err﹕ at com.parse.ParseDecoder.convertJSONArrayToList(ParseDecoder.java:45)
09-30 14:36:07.973      748-748/com.example.faang.testrequest W/System.err﹕ at com.parse.ParseDecoder.decode(ParseDecoder.java:71)
09-30 14:36:07.973      748-748/com.example.faang.testrequest W/System.err﹕ at com.parse.ParseDecoder.convertJSONObjectToMap(ParseDecoder.java:56)
09-30 14:36:07.983      748-748/com.example.faang.testrequest W/System.err﹕ at com.parse.ParseDecoder.decode(ParseDecoder.java:91)
09-30 14:36:07.983      748-748/com.example.faang.testrequest W/System.err﹕ at com.parse.ParseCloudCodeController.convertCloudResponse(ParseCloudCodeController.java:52)
09-30 14:36:08.023      748-748/com.example.faang.testrequest W/System.err﹕ at com.parse.ParseCloudCodeController$1.then(ParseCloudCodeController.java:36)
09-30 14:36:08.023      748-748/com.example.faang.testrequest W/System.err﹕ at bolts.Task$14.run(Task.java:784)
09-30 14:36:08.043      748-748/com.example.faang.testrequest W/System.err﹕ at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)

I currently use AndroidStudion 1.3.2, JavaSDK 1.8, AndroidSDK 6.0

Please help, Thanks

@grantland
Copy link
Contributor

Hrm it looks like the SDK is having some issues parsing the updatedAt date. Could you enable logging and post the log statement being output here: https://github.com/ParsePlatform/Parse-SDK-Android/blob/master/Parse/src/main/java/com/parse/ParseDateFormat.java#L45

Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);

@grantland grantland self-assigned this Sep 30, 2015
@Natcha119
Copy link
Author

Yes, there have the problem with the date.
Here is the log that I got

10-01 12:27:44.368  10473-10618/com.example.faang.testrequest V/ParseDateFormat﹕ could not parse date: {"iso":"2015-09-26T03:12:39.572Z","__type":"Date"}
    java.text.ParseException: Unparseable date: "{"iso":"2015-09-26T03:12:39.572Z","__type":"Date"}" (at offset 0)
            at java.text.DateFormat.parse(DateFormat.java:555)
            at com.parse.ParseDateFormat.parse(ParseDateFormat.java:42)
            at com.parse.ParseObject.mergeFromServer(ParseObject.java:990)
            at com.parse.ParseObject.fromJSON(ParseObject.java:686)
            at com.parse.ParseDecoder.decode(ParseDecoder.java:125)
            at com.parse.ParseDecoder.convertJSONArrayToList(ParseDecoder.java:45)
            at com.parse.ParseDecoder.decode(ParseDecoder.java:71)
            at com.parse.ParseDecoder.convertJSONObjectToMap(ParseDecoder.java:56)
            at com.parse.ParseDecoder.decode(ParseDecoder.java:91)
            at com.parse.ParseCloudCodeController.convertCloudResponse(ParseCloudCodeController.java:52)
            at com.parse.ParseCloudCodeController$1.then(ParseCloudCodeController.java:36)
            at bolts.Task$14.run(Task.java:784)
            at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
            at bolts.Task.completeImmediately(Task.java:775)
            at bolts.Task.continueWith(Task.java:574)
            at bolts.Task.continueWith(Task.java:585)
            at bolts.Task$12.then(Task.java:679)
            at bolts.Task$12.then(Task.java:667)
            at bolts.Task$15.run(Task.java:825)
            at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
            at bolts.Task.completeAfterTask(Task.java:816)
            at bolts.Task.access$200(Task.java:32)
            at bolts.Task$11.then(Task.java:621)
            at bolts.Task$11.then(Task.java:618)
            at bolts.Task.runContinuations(Task.java:861)
            at bolts.Task.access$600(Task.java:32)
            at bolts.Task$TaskCompletionSource.trySetResult(Task.java:916)
            at bolts.Task$TaskCompletionSource.setResult(Task.java:950)
            at bolts.Task$15$1.then(Task.java:842)
            at bolts.Task$15$1.then(Task.java:829)
            at bolts.Task$14.run(Task.java:784)
            at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
            at bolts.Task.completeImmediately(Task.java:775)
            at bolts.Task.continueWith(Task.java:574)
            at bolts.Task.continueWith(Task.java:585)
            at bolts.Task$15.run(Task.java:829)
            at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
            at bolts.Task.completeAfterTask(Task.java:816)
            at bolts.Task.access$200(Task.java:32)
            at bolts.Task$11.then(Task.java:621)
            at bolts.Task$11.then(Task.java:618)
            at bolts.Task.runContinuations(Task.java:861)
            at bolts.Task.access$600(Task.java:32)
            at bolts.Task$TaskCompletionSource.trySetResult(Task.java:916)
            at bolts.Task$TaskCompletionSource.setResult(Task.java:950)
            at bolts.Task$15$1.then(Task.java:842)
            at bolts.Task$15$1.then(Task.java:829)
            at bolts.Task$14.run(Task.java:784)
            at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
            at bolts.Task.completeImmediately(Task.java:775)
            at bolts.Task.continueWith(Task.java:574)
            at bolts.Task.continueWith(Task.java:585)
            at bolts.Task$15.run(Task.java:829)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)

@grantland
Copy link
Contributor

Seems to be a duplicate of #130, are you using Cloud Code and if so could you see if this still repros if you upgrade to latest JS SDK?

@Natcha119
Copy link
Author

In my dashboard, there show that I use Parse JavaScript SDK version "latest" but still having the problem.

@d370urn3ur
Copy link

I had the exact same problem, it's coming from the Javascript SDK, it was introduced in 1.6.0 and fixed in 1.6.2, but there is another bug in the JS SDK, using latest doesn't use the latest version, it is stuck on 1.6.0 so you need to specify the exact version 1.6.2 in the javascript SDK. See also #157.

@grantland
Copy link
Contributor

@Natcha119 could you please try that and update us on the results?

@kssaboo
Copy link

kssaboo commented Oct 15, 2015

I have a same problem. jssdk 1.6.6, android 1.10.3

@grantland
Copy link
Contributor

This was a bug in the JS SDK and has been resolved in 1.6.7: https://github.com/ParsePlatform/Parse-SDK-JS/releases/tag/v1.6.7

@kssaboo
Copy link

kssaboo commented Oct 16, 2015

Problem remains. jssdk 1.6.7, android 1.10.3.

could not parse date: {"iso":"2015-10-16T02:33:11.095Z","__type":"Date"}
java.text.ParseException: Unparseable date: "{"iso":"2015-10-16T02:33:11.095Z","__type":"Date"}" (at offset 0)
at java.text.DateFormat.parse(DateFormat.java:555)
at com.parse.ParseDateFormat.parse(ParseDateFormat.java:42)
at com.parse.ParseObject.mergeFromServer(ParseObject.java:990)
at com.parse.ParseObject.fromJSON(ParseObject.java:686)
at com.parse.ParseDecoder.decode(ParseDecoder.java:125)
at com.parse.ParseDecoder.convertJSONArrayToList(ParseDecoder.java:45)
at com.parse.ParseDecoder.decode(ParseDecoder.java:71)
at com.parse.ParseCloudCodeController.convertCloudResponse(ParseCloudCodeController.java:52)
at com.parse.ParseCloudCodeController$1.then(ParseCloudCodeController.java:36)
at bolts.Task$14.run(Task.java:784)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeImmediately(Task.java:775)
at bolts.Task.continueWith(Task.java:574)
at bolts.Task.continueWith(Task.java:585)
at bolts.Task$12.then(Task.java:679)
at bolts.Task$12.then(Task.java:667)
at bolts.Task$15.run(Task.java:825)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeAfterTask(Task.java:816)
at bolts.Task.access$200(Task.java:32)
at bolts.Task$11.then(Task.java:621)
at bolts.Task$11.then(Task.java:618)
at bolts.Task.runContinuations(Task.java:861)
at bolts.Task.access$600(Task.java:32)
at bolts.Task$TaskCompletionSource.trySetResult(Task.java:916)
at bolts.Task$TaskCompletionSource.setResult(Task.java:950)
at bolts.Task$15$1.then(Task.java:842)
at bolts.Task$15$1.then(Task.java:829)
at bolts.Task$14.run(Task.java:784)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeImmediately(Task.java:775)
at bolts.Task.continueWith(Task.java:574)
at bolts.Task.continueWith(Task.java:585)
at bolts.Task$15.run(Task.java:829)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeAfterTask(Task.java:816)
at bolts.Task.access$200(Task.java:32)
at bolts.Task$11.then(Task.java:621)
at bolts.Task$11.then(Task.java:618)
at bolts.Task.runContinuations(Task.java:861)
at bolts.Task.access$600(Task.java:32)
at bolts.Task$TaskCompletionSource.trySetResult(Task.java:916)
at bolts.Task$TaskCompletionSource.setResult(Task.java:950)
at bolts.Task$15$1.then(Task.java:842)
at bolts.Task$15$1.then(Task.java:829)
at bolts.Task$14.run(Task.java:784)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeImmediately(Task.java:775)
at bolts.Task.continueWith(Task.java:574)
at bolts.Task.continueWith(Task.java:585)
at bolts.Task$15.run(Task.java:829)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)

@grantland
Copy link
Contributor

If this is the case, could you please open a issue on https://github.com/ParsePlatform/Parse-SDK-JS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants