Fix GWT UI AddFileBox to provide path suggestions continuously
- How to reproduce the bug?
In ChangeScreen, click 'Edit', then 'Add...'. Type in some text, you
will get some path suggestions. Delete all the text you've typed in.
There will be no suggestion any more until the page is reloaded.
- Why does this happen?
The UI will continue create new query when the text box is focused
and the 'query' is null in RemoteSuggestOracle. When the text box is
cleared, it will result in a NullPointerException in
RESTApi.addParameter(String, String) when it calls
URL.encodeQueryString as the request.getQuery() is null. Once this
exception happens, onSuggestionReady will not be called and 'query'
field in RemoteSuggestOracle will not be reset to null. That's why
the UI will not try new Request until the page is reloaded.
This problem may be related to GWT 2.8 upgrade. It started behaving
differently after the upgrade. However, I haven't noticed this
problem for reviewers suggestion.
- Solution
Set the query to be empty when request.getQuery() is null.
Bug: Issue 5365
Change-Id: Ia0878b67aebde854012e3cacec51d922a9f32919
diff --git a/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/ui/RemoteSuggestOracle.java b/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/ui/RemoteSuggestOracle.java
index d66d6a6..41bf8ce 100644
--- a/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/ui/RemoteSuggestOracle.java
+++ b/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/ui/RemoteSuggestOracle.java
@@ -104,6 +104,9 @@
}
void start() {
+ if (request.getQuery() == null) {
+ request.setQuery("");
+ }
oracle.requestSuggestions(request, this);
}