Skip to content

Commit 044a0d2

Browse files
committed
Last field can be final too
1 parent b082910 commit 044a0d2

File tree

1 file changed

+7
-6
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/search/context

1 file changed

+7
-6
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/Context.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class Context {
6363
private final Query query;
6464
private final QueryBuilder qbuilder;
6565
private final LineMatcher[] m;
66-
String queryAsURI;
66+
private final String queryAsURI;
6767

6868
/**
6969
* Map whose keys tell which fields to look for in the source file, and
@@ -95,7 +95,9 @@ public Context(Query query, QueryBuilder qbuilder) {
9595
QueryMatchers qm = new QueryMatchers();
9696
m = qm.getMatchers(query, TOKEN_FIELDS);
9797
if (m != null) {
98-
buildQueryAsURI(qbuilder.getQueries());
98+
queryAsURI = buildQueryAsURI(qbuilder.getQueries());
99+
} else {
100+
queryAsURI = "";
99101
}
100102
}
101103

@@ -232,10 +234,9 @@ public boolean getContext2(RuntimeEnvironment env, IndexSearcher searcher,
232234
*
233235
* @param subqueries a map containing the query text for each field
234236
*/
235-
private void buildQueryAsURI(Map<String, String> subqueries) {
237+
private String buildQueryAsURI(Map<String, String> subqueries) {
236238
if (subqueries.isEmpty()) {
237-
queryAsURI = "";
238-
return;
239+
return "";
239240
}
240241
StringBuilder sb = new StringBuilder();
241242
for (Map.Entry<String, String> entry : subqueries.entrySet()) {
@@ -245,7 +246,7 @@ private void buildQueryAsURI(Map<String, String> subqueries) {
245246
.append('&');
246247
}
247248
sb.setLength(sb.length() - 1);
248-
queryAsURI = sb.toString();
249+
return sb.toString();
249250
}
250251

251252
private boolean alt = true;

0 commit comments

Comments
 (0)