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

BlobModule supports invokes virtual method String.equals() on null #18709

Closed
3 tasks done
zhaonian opened this issue Apr 5, 2018 · 11 comments
Closed
3 tasks done

BlobModule supports invokes virtual method String.equals() on null #18709

zhaonian opened this issue Apr 5, 2018 · 11 comments
Labels
Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@zhaonian
Copy link

zhaonian commented Apr 5, 2018

app breaks after upgrading to RN-0.54 due to exception in native call.

Environment

Environment:
OS: macOS High Sierra 10.13.4
Node: 9.7.1
Yarn: 1.3.2
npm: 5.8.0
Watchman: 4.9.0
Xcode: Xcode 9.3 Build version 9E145
Android Studio: 3.1 AI-173.4670197

Packages: (wanted => installed)
react: ^16.3.0-alpha.1 => 16.3.0-alpha.3
react-native: 0.54.2 => 0.54.2

Steps to Reproduce

  • upgrade to RN 0.54
  • debug in release mode on Android

Expected Behavior

the app should not break

Actual Behavior

04-05 06:43:35.824 20182-20198/com.science.ure E/Surface: getSlotFromBufferLocked: unknown buffer: 0xea08c500
04-05 06:43:37.388 20182-20211/com.science.ure E/unknown:ReactNative: Exception in native call
    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
        at com.facebook.react.modules.blob.BlobModule$2.supports(BlobModule.java:83)
        at com.facebook.react.modules.network.NetworkingModule.sendRequest(NetworkingModule.java:257)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
        at android.os.Looper.loop(Looper.java:148)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
        at java.lang.Thread.run(Thread.java:818)

image

the line of code that break in BlobModule is:

        boolean isRemote = scheme.equals("http") || scheme.equals("https");

looks like it did not successfully get the scheme, which should be returned by getScheme() from NetworkingModule.

Potential solution:
Add null-checking on scheme? #

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like your issue may be missing some necessary information. Can you run react-native info and edit your issue to include these results under the Environment section?

Thank you for your contributions.

@shockdesign
Copy link
Contributor

An easy fix would be just to replace that line with

boolean isRemote = "http".equals(scheme) || "https".equals(scheme);

@zhaonian
Copy link
Author

zhaonian commented Apr 6, 2018

@shockdesign thanks for your reply! :D I found what is causing this error.
I simply set a break point on this line and i found that react-native-svg-uri is passing local svg file as a uri, so this function getScheme() in the NetworkingModule.java returns null and breaks "http".equals(scheme).

@zhaonian zhaonian closed this as completed Apr 6, 2018
@Brian-Azizi
Copy link

has this been fixed now?

@jh3141
Copy link

jh3141 commented Apr 16, 2018

@Brian-Azizi - no, not fixed. Current master still has the same issue. Original poster found a workaround for his specific instance of the problem and therefore closed it, but the problem still persists for the rest of us...

@zhaonian
Copy link
Author

zhaonian commented Apr 16, 2018

Hi guys. Try to open Android studio and set a break point at this line and see where this 'null' comes from. Then you can go back to your react native code to fix it.

@thymikee
Copy link
Contributor

I, for example, bump into this while calling /graphql endpoint through non-native library (apollo-client).

@shockdesign
Copy link
Contributor

Submitted the fix ^^

facebook-github-bot pushed a commit that referenced this issue Apr 17, 2018
Summary:
Switch the equality check to avoid crash on the first item. The check can be on a null object and return the correct result.

Fixes #18709

Just a simple switch on equals, to make sure we're not bombing out by having a null scheme.

No related PRs and does not require a document change.

[ANDROID][BUGFIX][BlobModule] Switch equality check in BlobModule.java
Closes #18893

Differential Revision: D7658036

Pulled By: hramos

fbshipit-source-id: db61b98dae178dbbb645070f7b0d73ab43d30541
grabbou pushed a commit that referenced this issue Apr 27, 2018
Summary:
Switch the equality check to avoid crash on the first item. The check can be on a null object and return the correct result.

Fixes #18709

Just a simple switch on equals, to make sure we're not bombing out by having a null scheme.

No related PRs and does not require a document change.

[ANDROID][BUGFIX][BlobModule] Switch equality check in BlobModule.java
Closes #18893

Differential Revision: D7658036

Pulled By: hramos

fbshipit-source-id: db61b98dae178dbbb645070f7b0d73ab43d30541
macdoum1 pushed a commit to macdoum1/react-native that referenced this issue Jun 28, 2018
Summary:
Switch the equality check to avoid crash on the first item. The check can be on a null object and return the correct result.

Fixes facebook#18709

Just a simple switch on equals, to make sure we're not bombing out by having a null scheme.

No related PRs and does not require a document change.

[ANDROID][BUGFIX][BlobModule] Switch equality check in BlobModule.java
Closes facebook#18893

Differential Revision: D7658036

Pulled By: hramos

fbshipit-source-id: db61b98dae178dbbb645070f7b0d73ab43d30541
@vendramini
Copy link

Even using the fix, the problem persists here. Anyone else?

@hayait599
Copy link

same issue :(

@diegohdez90
Copy link

Same here.

@facebook facebook locked as resolved and limited conversation to collaborators Apr 6, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Apr 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

10 participants