You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by hy...@apache.org on 2019/10/07 18:03:23 UTC
[calcite] branch master updated: [CALCITE-3386]
CyclicMetadataException singleton instance causes confusion when debugging
(Zuozhi Wang)
This is an automated email from the ASF dual-hosted git repository.
hyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new 3f54108 [CALCITE-3386] CyclicMetadataException singleton instance causes confusion when debugging (Zuozhi Wang)
3f54108 is described below
commit 3f54108b7dcd4d2b89fc42faab145e2f82883791
Author: Zuozhi <zu...@alibaba-inc.com>
AuthorDate: Fri Oct 4 14:03:51 2019 -0700
[CALCITE-3386] CyclicMetadataException singleton instance causes confusion when debugging (Zuozhi Wang)
Fix misleading stack trace of Calcite's cyclic meta exception. Previously, a
singleton instance of CyclicMetadataException is reused. However it will lead
to wrong stack trace.
See https://stackoverflow.com/questions/15090664
Close #1484
---
.../org/apache/calcite/rel/metadata/CyclicMetadataException.java | 8 +-------
.../apache/calcite/rel/metadata/JaninoRelMetadataProvider.java | 4 ++--
.../calcite/rel/metadata/ReflectiveRelMetadataProvider.java | 2 +-
3 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/CyclicMetadataException.java b/core/src/main/java/org/apache/calcite/rel/metadata/CyclicMetadataException.java
index d4dd249..27f3e06 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/CyclicMetadataException.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/CyclicMetadataException.java
@@ -21,15 +21,9 @@ package org.apache.calcite.rel.metadata;
* computing metadata.
*/
public class CyclicMetadataException extends RuntimeException {
- /** Singleton instance. Since this exception is thrown for signaling purposes,
- * rather than on an actual error, re-using a singleton instance saves the
- * effort of constructing an exception instance. */
- @SuppressWarnings("ThrowableInstanceNeverThrown")
- public static final CyclicMetadataException INSTANCE =
- new CyclicMetadataException();
/** Creates a CyclicMetadataException. */
- private CyclicMetadataException() {
+ public CyclicMetadataException() {
super();
}
}
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java b/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
index 24054bb..c669ba3 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/JaninoRelMetadataProvider.java
@@ -273,9 +273,9 @@ public class JaninoRelMetadataProvider implements RelMetadataProvider {
.append(" if (v == ")
.append(NullSentinel.class.getName())
.append(".ACTIVE) {\n")
- .append(" throw ")
+ .append(" throw new ")
.append(CyclicMetadataException.class.getName())
- .append(".INSTANCE;\n")
+ .append("();\n")
.append(" }\n")
.append(" if (v == ")
.append(NullSentinel.class.getName())
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/ReflectiveRelMetadataProvider.java b/core/src/main/java/org/apache/calcite/rel/metadata/ReflectiveRelMetadataProvider.java
index 20185b7..64166f4 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/ReflectiveRelMetadataProvider.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/ReflectiveRelMetadataProvider.java
@@ -179,7 +179,7 @@ public class ReflectiveRelMetadataProvider
key1 = FlatLists.copyOf(args2);
}
if (mq.map.put(key1, NullSentinel.INSTANCE) != null) {
- throw CyclicMetadataException.INSTANCE;
+ throw new CyclicMetadataException();
}
try {
return handlerMethod.invoke(target, args1);