Fixed comparison on possible null object (#19675)

Summary:
Motivation: getting NPE on BlobModule part

<img width="1718" alt="screen shot 2018-06-12 at 3 03 48 pm" src="https://user-images.githubusercontent.com/4340636/41292212-31e0acc8-6e52-11e8-916a-dd6fc2bb695a.png">

Should still build and pass all tests since project settings changes should be safe changes.

<!--
  Required: Write your test plan here. If you changed any code, please provide us with
  clear instructions on how you verified your changes work. Bonus points for screenshots and videos!
-->

No documentation change is required
<!--
  Does this PR require a documentation change?
  Create a PR at https://github.com/facebook/react-native-website and add a link to it here.
-->

<!--
  Required.
  Help reviewers and the release process by writing your own release notes. See below for an example.
-->

[ANDROID][BUGFIX][BlobModule] safe equals checks

<!--
  **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

    CATEGORY
  [----------]      TYPE
  [ CLI      ] [-------------]    LOCATION
  [ DOCS     ] [ BREAKING    ] [-------------]
  [ GENERAL  ] [ BUGFIX      ] [ {Component} ]
  [ INTERNAL ] [ ENHANCEMENT ] [ {Filename}  ]
  [ IOS      ] [ FEATURE     ] [ {Directory} ]   |-----------|
  [ ANDROID  ] [ MINOR       ] [ {Framework} ] - | {Message} |
  [----------] [-------------] [-------------]   |-----------|

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Closes https://github.com/facebook/react-native/pull/19675

Differential Revision: D8380228

Pulled By: hramos

fbshipit-source-id: 1d3caefdb7a7d638228490ef7b3771617745d26f
This commit is contained in:
Choma, Matus 2018-06-12 08:42:14 -07:00 committed by Facebook Github Bot
parent 123512c5de
commit cc07c9f0a3
1 changed files with 4 additions and 4 deletions

View File

@ -81,7 +81,7 @@ public class BlobModule extends ReactContextBaseJavaModule {
String scheme = uri.getScheme();
boolean isRemote = "http".equals(scheme) || "https".equals(scheme);
return (!isRemote && responseType.equals("blob"));
return (!isRemote && "blob".equals(responseType));
}
@Override
@ -133,7 +133,7 @@ public class BlobModule extends ReactContextBaseJavaModule {
new NetworkingModule.ResponseHandler() {
@Override
public boolean supports(String responseType) {
return responseType.equals("blob");
return "blob".equals(responseType);
}
@Override
@ -236,7 +236,7 @@ public class BlobModule extends ReactContextBaseJavaModule {
}
private String getNameFromUri(Uri contentUri) {
if (contentUri.getScheme().equals("file")) {
if ("file".equals(contentUri.getScheme())) {
return contentUri.getLastPathSegment();
}
String[] projection = {MediaStore.MediaColumns.DISPLAY_NAME};
@ -256,7 +256,7 @@ public class BlobModule extends ReactContextBaseJavaModule {
}
private long getLastModifiedFromUri(Uri contentUri) {
if (contentUri.getScheme().equals("file")) {
if ("file".equals(contentUri.getScheme())) {
return new File(contentUri.toString()).lastModified();
}
return 0;