Use match() in matchOrNull() in MatchCache

These two methods were almost the same, so reduce the code by sharing
more while bringing their implementations inline with each other. This
results in no longer putting a null into the cache when it already is
null.

Change-Id: I6182e833e88b4a319840d56cc09557acb1ba6035
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/MatchCache.java b/src/main/java/com/googlesource/gerrit/plugins/task/MatchCache.java
index 7bdb95d..ab51a55 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/task/MatchCache.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/task/MatchCache.java
@@ -28,6 +28,14 @@
     this.predicateCache = predicateCache;
   }
 
+  public Boolean matchOrNull(ChangeData changeData, String query) {
+    try {
+      return match(changeData, query);
+    } catch (StorageException | QueryParseException e) {
+    }
+    return null;
+  }
+
   public boolean match(ChangeData changeData, String query)
       throws StorageException, QueryParseException {
     if (query == null) {
@@ -41,21 +49,6 @@
     return isMatched;
   }
 
-  public Boolean matchOrNull(ChangeData changeData, String query) {
-    if (query == null) {
-      return null;
-    }
-    Boolean isMatched = resultByChangeByQuery.get(query, changeData.getId());
-    if (isMatched == null) {
-      try {
-        isMatched = predicateCache.matchWithExceptions(changeData, query);
-      } catch (QueryParseException | RuntimeException e) {
-      }
-      resultByChangeByQuery.put(query, changeData.getId(), isMatched);
-    }
-    return isMatched;
-  }
-
   public void initStatistics() {
     resultByChangeByQuery.initStatistics();
   }