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

NullPointerException in ManeuverView #122

Closed
juschmitt opened this issue Oct 21, 2024 · 0 comments · Fixed by #123
Closed

NullPointerException in ManeuverView #122

juschmitt opened this issue Oct 21, 2024 · 0 comments · Fixed by #123

Comments

@juschmitt
Copy link
Contributor

Android API:
Maplibre Navigation SDK version:

We're currently experiencing crashes in our app coming from a NullPointerException thats being thrown in the ManeuverView:

java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference
    at java.lang.String.contains(String.java:2722)
    at com.mapbox.services.android.navigation.ui.v5.instruction.maneuver.ManeuverView.onDraw(ManeuverView.java:243)

Which happens right here in the contains(maneuverModifier)

if (STEP_MANEUVER_MODIFIER_LEFT.equals(drivingSide) && STEP_MANEUVER_MODIFIER_UTURN.contains(maneuverModifier)) {

The Problem we're facing is, that when the drivingSide is "left" and the maneuverModifier is null the contains() call will crash as it tries to call toString() on null.
The banner instructions we get from our routing engine for the type "arrive" do not contain a modifier attribute. They look something like this:

[
  {
    "primary": {
      "text": "You have arrived at your Destination.",
      "type": "arrive",
      "components": [
        {
          "text": "You have arrived at your Destination.",
          "type": "text"
        }
      ]
    },
    "distanceAlongGeometry": ...
  }
]

Now, I believe that the ManeuverView should be able to handle the maneuverModifier being null (most of the code hints at this being the case), just this one call is not able to handle a null parameter.

Am I correct that this STEP_MANEUVER_MODIFIER_UTURN.contains(maneuverModifier) should actually be a STEP_MANEUVER_MODIFIER_UTURN.equals(maneuverModifier) as that would be handling the parameter being null?

I will also open a PR for this that should fix it based on my assumption. So please correct me if I am wrong and I will adjust the PR accordingly.

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 a pull request may close this issue.

1 participant