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

[7.1.4] Android null pointer exception #549

Closed
cristianoccazinsp opened this issue Dec 9, 2021 · 1 comment · Fixed by #550
Closed

[7.1.4] Android null pointer exception #549

cristianoccazinsp opened this issue Dec 9, 2021 · 1 comment · Fixed by #550
Labels
bug Something isn't working

Comments

@cristianoccazinsp
Copy link
Contributor

Environment

System:
    OS: macOS 11.6
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 208.78 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.6 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 7.24.0 - /usr/local/bin/npm
    Watchman: 2021.06.07.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7678000
    Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.66.3 => 0.66.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Platforms

Android

Versions

  • Android: 11, 12
  • react-native-netinfo: 7.1.4
  • react-native: 0.66.3
  • react: 17.0.2

Description

#547 introduced a null pointer exception.

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.net.NetworkCapabilities.hasCapability(int)' on a null object reference
        at com.reactnativecommunity.netinfo.NetworkCallbackConnectivityReceiver.updateAndSend(NetworkCallbackConnectivityReceiver.java:104)
        at com.reactnativecommunity.netinfo.NetworkCallbackConnectivityReceiver$1.run(NetworkCallbackConnectivityReceiver.java:136)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8633)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

This is most likely related to two threads modifying the instance variables while the code is running.

Reproducible Demo

@cristianoccazinsp cristianoccazinsp added the bug Something isn't working label Dec 9, 2021
@cristianoccazinsp
Copy link
Contributor Author

Also, the two crashes I received a report like this, were from an app fully in background started in headless.

cristianoccazinsp pushed a commit to cristianoccazinsp/react-native-netinfo that referenced this issue Dec 9, 2021
Make sure we use a final reference to the instance variables in case they are modified in another callback while being used.
cristianoccazinsp pushed a commit to cristianoccazinsp/react-native-netinfo that referenced this issue Dec 9, 2021
Make sure we use a final reference to the instance variables in case they are modified in another callback while being used.
mikehardy pushed a commit that referenced this issue Dec 9, 2021
…afety #549 (#550)

Make sure we use a final reference to the instance variables in case they are modified in another callback while being used.

Co-authored-by: Cristiano Coelho <cristianocca@hotmail.com>
github-actions bot pushed a commit that referenced this issue Dec 9, 2021
## [7.1.5](v7.1.4...v7.1.5) (2021-12-09)

### Bug Fixes

* **android:** use method-local ref to instance var for multi-thread safety [#549](#549) ([#550](#550)) ([81bbc87](81bbc87))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant