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

Added logs and handle CompletableFutures exception #1600

Merged
merged 2 commits into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.mozilla.vrbrowser.search.suggestions;

import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;

Expand All @@ -17,6 +18,8 @@

public class SuggestionsProvider {

private static final String LOGTAG = SuggestionsProvider.class.getSimpleName();
keianhzo marked this conversation as resolved.
Show resolved Hide resolved

public class DefaultSuggestionsComparator implements Comparator {

public int compare(Object obj1, Object obj2) {
Expand Down Expand Up @@ -90,6 +93,11 @@ public CompletableFuture<List<SuggestionItem>> getBookmarkSuggestions(@NonNull L
items.sort(mComparator);
}
future.complete(items);

}).exceptionally(th -> {
Log.e(LOGTAG, "Error getting bookmarks suggestions: " + th.getLocalizedMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the exceptions do not contain PII? I'm paranoid after all the work it took to clean up FxR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being part of AC I guess they don't, maybe @pocmo can answer that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would hope not but since these API deal with bookmarks and history I could conceive of something get leaked out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this calls into Kotlin and Rust code of AS libraries we can't really guarantee that at the AC level.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keianhzo we should probably make the Logs debug then so they get stripped out for release?

future.complete(items);
return null;
});

return future;
Expand All @@ -111,6 +119,11 @@ public CompletableFuture<List<SuggestionItem>> getHistorySuggestions(@NonNull fi
items.sort(mComparator);
}
future.complete(items);

}).exceptionally(th -> {
Log.e(LOGTAG, "Error getting history suggestions: " + th.getLocalizedMessage());
future.complete(items);
return null;
});

return future;
Expand Down Expand Up @@ -152,6 +165,11 @@ public CompletableFuture<List<SuggestionItem>> getSearchEngineSuggestions(@NonNu
items.sort(mComparator);
}
future.complete(items);

}).exceptionally(th -> {
Log.e(LOGTAG, "Error getting search engine suggestions: " + th.getLocalizedMessage());
future.complete(items);
return null;
});

return future;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.MotionEvent;
Expand Down Expand Up @@ -52,6 +53,9 @@
import mozilla.components.ui.autocomplete.InlineAutocompleteEditText;

public class NavigationURLBar extends FrameLayout {

private static final String LOGTAG = NavigationURLBar.class.getSimpleName();

private InlineAutocompleteEditText mURL;
private UIButton mMicrophoneButton;
private UIButton mUAModeButton;
Expand Down Expand Up @@ -255,7 +259,10 @@ private void handleBookmarkClick() {
bookmarkStore.deleteBookmarkByURL(url);
setBookmarked(false);
}
}, mUIThreadExecutor);
}, mUIThreadExecutor).exceptionally(th -> {
Log.e(LOGTAG, "Error getting bookmarks: " + th.getLocalizedMessage());
return null;
});

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class NavigationBarWidget extends UIWidget implements GeckoSession.Naviga
SharedPreferences.OnSharedPreferenceChangeListener, SuggestionsWidget.URLBarPopupDelegate,
BookmarkListener, TrayListener {

private static final String LOGTAG = "VRB";
private static final String LOGTAG = NavigationBarWidget.class.getSimpleName();

private AudioEngine mAudio;
private UIButton mBackButton;
Expand Down Expand Up @@ -900,7 +900,10 @@ public void OnShowSearchPopup() {
mPopup.show(CLEAR_FOCUS);
}

}, new UIThreadExecutor());
}, new UIThreadExecutor()).exceptionally(th -> {
Log.e(LOGTAG, "Error getting suggestions: " + th.getLocalizedMessage());
return null;
});
}

@Override
Expand Down