cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [cayenne] branch master updated: CAY-2720 ConcurrentModificationException in the TypeAwareSQLTreeProcessor - minor optimization
Date Thu, 09 Sep 2021 09:26:36 GMT
This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/master by this push:
     new 4f9b591  CAY-2720 ConcurrentModificationException in the TypeAwareSQLTreeProcessor
  - minor optimization
4f9b591 is described below

commit 4f9b591af0675fbea1bba34090a4452143823fab
Author: Nikita Timofeev <stariy95@gmail.com>
AuthorDate: Thu Sep 9 12:26:29 2021 +0300

    CAY-2720 ConcurrentModificationException in the TypeAwareSQLTreeProcessor
      - minor optimization
---
 .../cayenne/access/sqlbuilder/sqltree/PerAttributeChildProcessor.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/sqlbuilder/sqltree/PerAttributeChildProcessor.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/sqlbuilder/sqltree/PerAttributeChildProcessor.java
index 9677ffc..dc278dd 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/sqlbuilder/sqltree/PerAttributeChildProcessor.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/sqlbuilder/sqltree/PerAttributeChildProcessor.java
@@ -35,18 +35,20 @@ public class PerAttributeChildProcessor<T extends Node> implements
ChildProcesso
     private final Map<DbAttribute, ChildProcessor<T>> processorByAttribute =
new ConcurrentHashMap<>();
     private final Function<T, DbAttribute> attributeMapper;
     private final Function<DbAttribute, ChildProcessor<T>> processorFactory;
+    private final ChildProcessor<T> nullProcessor;
 
     public PerAttributeChildProcessor(Function<T, DbAttribute> attributeMapper,
                                       Function<DbAttribute, ChildProcessor<T>>
processorFactory) {
         this.processorFactory = processorFactory;
         this.attributeMapper = attributeMapper;
+        this.nullProcessor = processorFactory.apply(null);
     }
 
     @Override
     public Optional<Node> process(Node parent, T child, int index) {
         DbAttribute dbAttribute = attributeMapper.apply(child);
         if(dbAttribute == null) {
-            return processorFactory.apply(null).process(parent, child, index);
+            return nullProcessor.process(parent, child, index);
         }
         return processorByAttribute
                 .computeIfAbsent(dbAttribute, processorFactory)

Mime
View raw message