Home » Android » Android Parse SDK i/o failure unknown format (magic number 227b)

Android Parse SDK i/o failure unknown format (magic number 227b)

Posted by: admin June 15, 2020 Leave a comment

Questions:

I am trying to recover my records from Parse. The class is called Rating. When I try to find less than 5 records, there are no problems. But when I try to find more records, the next stack is shown:

com.parse.ParseRequest$ParseRequestException: i/o failure
at com.parse.ParseRequest.newTemporaryException(ParseRequest.java:289)
at com.parse.ParseRequest$2.then(ParseRequest.java:144)
at com.parse.ParseRequest$2.then(ParseRequest.java:138)
at bolts.Task$15.run(Task.java:839)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.io.IOException: unknown format (magic number 227b)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:101)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:81)
at com.parse.ParseDecompressInterceptor.intercept(ParseDecompressInterceptor.java:40)
at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:147)
at com.parse.ParsePlugins$1.intercept(ParsePlugins.java:115)
at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:147)
at com.parse.ParseHttpClient.execute(ParseHttpClient.java:122)
at com.parse.ParseRequest$3.then(ParseRequest.java:135)
at com.parse.ParseRequest$3.then(ParseRequest.java:132)
at bolts.Task$15.run(Task.java:839)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeAfterTask(Task.java:830)
at bolts.Task.continueWithTask(Task.java:642)
at bolts.Task.continueWithTask(Task.java:653)
at bolts.Task$13.then(Task.java:745)
at bolts.Task$13.then(Task.java:733)
... 4 more

Anyone has any clue why this is happening?

How to&Answers:

To make it work I am using the 1.11.0 version ( compile ‘com.parse:parse-android:1.11.0’ ). So far no problems.

Answer:

I have the same bug but with me the query work fine with Android Api +19 , older versions throws this exception

Answer:

Create a class ParseLogInterceptor

public class ParseLogInterceptor implements ParseNetworkInterceptor {
@Override
public ParseHttpResponse intercept(Chain chain) throws IOException {
  ParseHttpRequest request = chain.getRequest();

  ParseHttpResponse response = chain.proceed(request);

  // Consume the response body
  ByteArrayOutputStream responseBodyByteStream = new ByteArrayOutputStream();
  int n;
  byte[] buffer = new byte[1024];
  while ((n = response.getContent().read(buffer, 0, buffer.length)) != -1) {
    responseBodyByteStream.write(buffer, 0, n);
  }
  final byte[] responseBodyBytes = responseBodyByteStream.toByteArray();
  Log.i("Response_Body", new String(responseBodyBytes));

  // Make a new response before return the response
  response = new ParseHttpResponse.Builder(response)
      .setContent(new ByteArrayInputStream(responseBodyBytes))
      .build();

  return response;
 }}

Add this before Parse.initialize():

Parse.addParseNetworkInterceptor(new ParseLogInterceptor());

It works for me.

Source: https://github.com/ParsePlatform/Parse-SDK-Android/issues/325

Answer:

This is a bug in Parse 1.12.0. I opened an issue on their repository at https://github.com/ParsePlatform/Parse-SDK-Android/issues/355 – the developers have reproduced it and are working on a fix.

As others have mentioned, the current workaround is to simply fallback to 1.11.0, or to compile against API19 or above.