Skip to content

Avoid add unnecessary ParseDecompressInterceptor #358

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

Conversation

wangmengyan95
Copy link
Contributor

Fixes #355
We set network interceptor like this, when developers do not add external interceptors, parameter interceptors is null

 initialize(builder.setNetworkInterceptors(interceptors)
    .setLocalDatastoreEnabled(isLocalDatastoreEnabled)
    .build()
 );

link

For the Configuration.builder, its interceptors will never be null

/* package for tests */ Builder setNetworkInterceptors(Collection<ParseNetworkInterceptor> interceptors) {
  if (this.interceptors == null) {
    this.interceptors = new ArrayList<>();
  } else {
    this.interceptors.clear();
  }

  if (interceptors != null) {
    this.interceptors.addAll(interceptors);
  }
  return this;
}

link

Thus, in Parse.initialize(), the checking is actually useless since configuration.interceptors will never be null. This will make us always add ParseDecompressInterceptor.

// If we have interceptors in list, we have to initialize all http clients and add interceptors
if (configuration.interceptors != null) {
  initializeParseHttpClientsWithParseNetworkInterceptors(configuration.interceptors);
}

link.

To fix this, we should also check the size of the list.
cc @richardjrossiii

@facebook-github-bot
Copy link

By analyzing the blame information on this pull request, we identified @richardjrossiii, @grantland and @wangmengyan95 to be potential reviewers.

@grantland
Copy link
Contributor

LGTM

@grantland grantland assigned wangmengyan95 and unassigned grantland Jan 21, 2016
@wangmengyan95 wangmengyan95 reopened this Jan 21, 2016
wangmengyan95 added a commit that referenced this pull request Jan 21, 2016
…cessary_ParseDecompressInterceptor

Avoid add unnecessary ParseDecompressInterceptor
@wangmengyan95 wangmengyan95 merged commit 033d642 into master Jan 21, 2016
@wangmengyan95 wangmengyan95 deleted the wangmengyan.avoid_add_unnecessary_ParseDecompressInterceptor branch January 21, 2016 00:36
@grantland grantland modified the milestone: 1.13.0 Jan 21, 2016
@grantland grantland mentioned this pull request Jan 22, 2016
4 tasks
@facebook-github-bot
Copy link

@wangmengyan95 updated the pull request.

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

Successfully merging this pull request may close these issues.

ParseRequestException: i/o failure in ParseDecompressInterceptor on 1.12.0 on API<19 devices
3 participants