[ 
https://issues.apache.org/jira/browse/KYLIN-3588?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16633214#comment-16633214
 ] 

ASF GitHub Bot commented on KYLIN-3588:
---------------------------------------

shaofengshi closed pull request #248: KYLIN-3588, fix potentially duplicate 
putting in RemoveBlackoutRealiz…
URL: https://github.com/apache/kylin/pull/248
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/query/src/main/java/org/apache/kylin/query/routing/rules/RemoveBlackoutRealizationsRule.java
 
b/query/src/main/java/org/apache/kylin/query/routing/rules/RemoveBlackoutRealizationsRule.java
index c64f6dae73..278bb46452 100644
--- 
a/query/src/main/java/org/apache/kylin/query/routing/rules/RemoveBlackoutRealizationsRule.java
+++ 
b/query/src/main/java/org/apache/kylin/query/routing/rules/RemoveBlackoutRealizationsRule.java
@@ -59,13 +59,16 @@ public static boolean accept(IRealization real) {
     private static IRealizationFilter getFilterImpl(KylinConfig conf) {
         IRealizationFilter filter = filters.get(conf);
         if (filter == null) {
-            try {
-                Class<? extends IRealizationFilter> clz = 
ClassUtil.forName(conf.getQueryRealizationFilter(), IRealizationFilter.class);
-                filter = 
clz.getConstructor(KylinConfig.class).newInstance(conf);
-            } catch (Exception e) {
-                throw new RuntimeException(e);
+            synchronized (RemoveBlackoutRealizationsRule.class) {
+                try {
+                    Class<? extends IRealizationFilter> clz = 
ClassUtil.forName(conf.getQueryRealizationFilter(),
+                            IRealizationFilter.class);
+                    filter = 
clz.getConstructor(KylinConfig.class).newInstance(conf);
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+                filters.put(conf, filter);
             }
-            filters.put(conf, filter);
         }
         return filter;
     }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Potentially duplicate put to RemoveBlackoutRealizationsRule#filters map
> -----------------------------------------------------------------------
>
>                 Key: KYLIN-3588
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3588
>             Project: Kylin
>          Issue Type: Bug
>            Reporter: Ted Yu
>            Assignee: jiatao.tao
>            Priority: Minor
>             Fix For: v2.6.0
>
>
> Here is related code:
> {code}
>         IRealizationFilter filter = filters.get(conf);
>         if (filter == null) {
>             try {
>                 Class<? extends IRealizationFilter> clz = 
> ClassUtil.forName(conf.getQueryRealizationFilter(), IRealizationFilter.class);
>                 filter = 
> clz.getConstructor(KylinConfig.class).newInstance(conf);
>             } catch (Exception e) {
>                 throw new RuntimeException(e);
>             }
>             filters.put(conf, filter);
> {code}
> Two threads may find out there is no filter for conf, they would proceed with 
> creation of IRealizationFilter instances and try to put into the map.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to