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

MapboxDirections: onResponse called twice #682

Closed
palto-blubek opened this issue Dec 7, 2017 · 1 comment
Closed

MapboxDirections: onResponse called twice #682

palto-blubek opened this issue Dec 7, 2017 · 1 comment

Comments

@palto-blubek
Copy link

When using the directions API like so:

builder = (...)
MapboxDirections client = builder.build();
 client.enqueueCall(new Callback<DirectionsResponse>() {
                @Override
                public void onResponse(@NonNull Call<DirectionsResponse> call, @NonNull Response<DirectionsResponse> response) {
                    (...)
                }

                @Override
                public void onFailure(@NonNull Call<DirectionsResponse> call, @NonNull Throwable throwable) {
                    (...)
                }
            });

if no route can be found, then onResponse will be called twice.

This is highly surprising/unexpected, and in our case, caused a crash.

Expected Behavior

This should be called only once.

Current Behavior

It is called twice.

Possible Solution

a return should be added right after this line:
https://github.com/mapbox/mapbox-java/blob/master/services-directions/src/main/java/com/mapbox/api/directions/v5/MapboxDirections.java#L161

Steps to Reproduce

A call should be made that results in a NoRoute response (for instance, 2.308538,48.852698 to 120.960515,23.69781).
See above.

Context (Environment)

In our case this produced a crash because we use an Rx SingleEmitter and onError must not be called twice.

Detailed Description

See "possible solution" above.

Possible Implementation

See "possible solution" above.

@cammace cammace added this to the v3.0.0 milestone Dec 7, 2017
@cammace
Copy link
Contributor

cammace commented Dec 7, 2017

Thanks for reporting, I suspect you're correct with the possible solution but will need to double check this and add a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants