Fixed bug in ParseOkHttpClient which didn't handle ParseFile File upl… #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…oads correctly.
This check was unnecessary and in the event of a ParseFileHttpBody it would result in a null body for the Http POST which throws an exception.
Alternatively it could be replaced with the following:
if(parseBody instanceof ParseByteArrayHttpBody || parseBody instanceof ParseFileHttpBody) {
okHttpRequestBody = new ParseOkHttpRequestBody(parseBody);
}
However both of those classes extend ParseHttpBody and they are the only classes that do so and the constructor for ParseOkHttpRequestBody is expecting type ParseHttpBody which they both extend so it seems as though the check is unnecessary.
This fixes File uploads as part of a ParseFile. Previously it was throwing the exception:
com.parse.ParseException: java.lang.IllegalArgumentException: method POST must have a request body.
01-22 14:03:12.982 24657-24657/com.plus11.ncredible W/System.err: at com.parse.ParseTaskUtils$2$1.run(ParseTaskUtils.java:114)
01-22 14:03:12.983 24657-24657/com.plus11.ncredible W/System.err: at android.os.Handler.handleCallback(Handler.java:739)
01-22 14:03:12.983 24657-24657/com.plus11.ncredible W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
01-22 14:03:12.983 24657-24657/com.plus11.ncredible W/System.err: at android.os.Looper.loop(Looper.java:148)
01-22 14:03:12.983 24657-24657/com.plus11.ncredible W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
01-22 14:03:12.983 24657-24657/com.plus11.ncredible W/System.err: at java.lang.reflect.Method.invoke(Native Method)
01-22 14:03:12.983 24657-24657/com.plus11.ncredible W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
01-22 14:03:12.983 24657-24657/com.plus11.ncredible W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-22 14:03:12.984 24657-24657/com.plus11.ncredible W/System.err: Caused by: java.lang.IllegalArgumentException: method POST must have a request body.
01-22 14:03:12.984 24657-24657/com.plus11.ncredible W/System.err: at com.squareup.okhttp.Request$Builder.method(Request.java:256)
01-22 14:03:12.984 24657-24657/com.plus11.ncredible W/System.err: at com.squareup.okhttp.Request$Builder.post(Request.java:229)
01-22 14:03:12.985 24657-24657/com.plus11.ncredible W/System.err: at com.parse.ParseOkHttpClient.getRequest(ParseOkHttpClient.java:157)
01-22 14:03:12.985 24657-24657/com.plus11.ncredible W/System.err: at com.parse.ParseOkHttpClient.executeInternal(ParseOkHttpClient.java:66)
01-22 14:03:12.985 24657-24657/com.plus11.ncredible W/System.err: at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:158)
01-22 14:03:12.985 24657-24657/com.plus11.ncredible W/System.err: at com.parse.ParsePlugins$1.intercept(ParsePlugins.java:115)
01-22 14:03:12.985 24657-24657/com.plus11.ncredible W/System.err: at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:147)
01-22 14:03:12.985 24657-24657/com.plus11.ncredible W/System.err: at com.parse.ParseHttpClient.execute(ParseHttpClient.java:122)
01-22 14:03:12.986 24657-24657/com.plus11.ncredible W/System.err: at com.parse.ParseRequest$3.then(ParseRequest.java:136)
01-22 14:03:12.986 24657-24657/com.plus11.ncredible W/System.err: at com.parse.ParseRequest$3.then(ParseRequest.java:133)
01-22 14:03:12.986 24657-24657/com.plus11.ncredible W/System.err: at bolts.Task$15.run(Task.java:839)
01-22 14:03:12.986 24657-24657/com.plus11.ncredible W/System.err: at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
01-22 14:03:12.986 24657-24657/com.plus11.ncredible W/System.err: at bolts.Task.completeAfterTask(Task.java:830)
01-22 14:03:12.986 24657-24657/com.plus11.ncredible W/System.err: at bolts.Task.continueWithTask(Task.java:642)
01-22 14:03:12.987 24657-24657/com.plus11.ncredible W/System.err: at bolts.Task.continueWithTask(Task.java:653)
01-22 14:03:12.987 24657-24657/com.plus11.ncredible W/System.err: at bolts.Task$13.then(Task.java:745)
01-22 14:03:12.987 24657-24657/com.plus11.ncredible W/System.err: at bolts.Task$13.then(Task.java:733)
01-22 14:03:12.987 24657-24657/com.plus11.ncredible W/System.err: at bolts.Task$15.run(Task.java:839)
01-22 14:03:12.987 24657-24657/com.plus11.ncredible W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
01-22 14:03:12.987 24657-24657/com.plus11.ncredible W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
01-22 14:03:12.988 24657-24657/com.plus11.ncredible W/System.err: at java.lang.Thread.run(Thread.java:818)