Share MatchCache across root nodes for the same change When the MatchCache was introduced, it was not shared across roots, fix that. Change-Id: I9e9e6a6ee88b83462fd9473d6dac36679f4cae37
diff --git a/src/main/java/com/googlesource/gerrit/plugins/task/TaskAttributeFactory.java b/src/main/java/com/googlesource/gerrit/plugins/task/TaskAttributeFactory.java index c0ba9d7..2648701 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/task/TaskAttributeFactory.java +++ b/src/main/java/com/googlesource/gerrit/plugins/task/TaskAttributeFactory.java
@@ -92,13 +92,14 @@ } protected PluginDefinedInfo createWithExceptions(ChangeData c) { + MatchCache matchCache = new MatchCache(predicateCache, c); TaskPluginAttribute a = new TaskPluginAttribute(); try { for (Node node : definitions.getRootNodes(c)) { if (node == null) { a.roots.add(invalid()); } else { - new AttributeFactory(node).create().ifPresent(t -> a.roots.add(t)); + new AttributeFactory(node, matchCache).create().ifPresent(t -> a.roots.add(t)); } } } catch (ConfigInvalidException | IOException | OrmException e) { @@ -117,10 +118,6 @@ protected Task task; protected TaskAttribute attribute; - protected AttributeFactory(Node node) { - this(node, new MatchCache(predicateCache, node.getChangeData())); - } - protected AttributeFactory(Node node, MatchCache matchCache) { this.node = node; this.matchCache = matchCache;