diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java index a80feb9..c92b4f6 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java @@ -1613,16 +1613,20 @@ public static boolean isDeterministic(GenericUDF genericUDF) { // the deterministic annotation declares return false; } - UDFType genericUDFType = genericUDF.getClass().getAnnotation(UDFType.class); - if (genericUDFType != null && genericUDFType.deterministic() == false) { - return false; + synchronized(UDFType.class) { + UDFType genericUDFType = genericUDF.getClass().getAnnotation(UDFType.class); + if (genericUDFType != null && genericUDFType.deterministic() == false) { + return false; + } } if (genericUDF instanceof GenericUDFBridge) { GenericUDFBridge bridge = (GenericUDFBridge) (genericUDF); - UDFType bridgeUDFType = bridge.getUdfClass().getAnnotation(UDFType.class); - if (bridgeUDFType != null && bridgeUDFType.deterministic() == false) { - return false; + synchronized(UDFType.class) { + UDFType bridgeUDFType = bridge.getUdfClass().getAnnotation(UDFType.class); + if (bridgeUDFType != null && bridgeUDFType.deterministic() == false) { + return false; + } } } @@ -1638,16 +1642,20 @@ public static boolean isDeterministic(GenericUDF genericUDF) { * Returns whether a GenericUDF is stateful or not. */ public static boolean isStateful(GenericUDF genericUDF) { - UDFType genericUDFType = genericUDF.getClass().getAnnotation(UDFType.class); - if (genericUDFType != null && genericUDFType.stateful()) { - return true; + synchronized(UDFType.class) { + UDFType genericUDFType = genericUDF.getClass().getAnnotation(UDFType.class); + if (genericUDFType != null && genericUDFType.stateful()) { + return true; + } } if (genericUDF instanceof GenericUDFBridge) { GenericUDFBridge bridge = (GenericUDFBridge) genericUDF; - UDFType bridgeUDFType = bridge.getUdfClass().getAnnotation(UDFType.class); - if (bridgeUDFType != null && bridgeUDFType.stateful()) { - return true; + synchronized(UDFType.class) { + UDFType bridgeUDFType = bridge.getUdfClass().getAnnotation(UDFType.class); + if (bridgeUDFType != null && bridgeUDFType.stateful()) { + return true; + } } } diff --git ql/src/java/org/apache/hadoop/hive/ql/plan/GroupByDesc.java ql/src/java/org/apache/hadoop/hive/ql/plan/GroupByDesc.java index 5aa3e82..df32949 100644 --- ql/src/java/org/apache/hadoop/hive/ql/plan/GroupByDesc.java +++ ql/src/java/org/apache/hadoop/hive/ql/plan/GroupByDesc.java @@ -228,9 +228,11 @@ public boolean isDistinctLike() { for (AggregationDesc ad : aggregators) { if (!ad.getDistinct()) { GenericUDAFEvaluator udafEval = ad.getGenericUDAFEvaluator(); - UDFType annot = udafEval.getClass().getAnnotation(UDFType.class); - if (annot == null || !annot.distinctLike()) { - return false; + synchronized(UDFType.class) { + UDFType annot = udafEval.getClass().getAnnotation(UDFType.class); + if (annot == null || !annot.distinctLike()) { + return false; + } } } }