zuozhiw commented on a change in pull request #1484: [CALCITE-3386] 
CyclicMetadataException singleton instance causes confusion when debugging
URL: https://github.com/apache/calcite/pull/1484#discussion_r331727687
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/rel/metadata/CyclicMetadataException.java
 ##########
 @@ -21,15 +21,12 @@
  * 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() {
+  /**
+   * Creates a CyclicMetadataException.
+   * Reusing a singleton instance is a bad idea because of wrong stack trace.
+   * See https://stackoverflow.com/questions/15090664
 
 Review comment:
   this is removed from the code and moved to commit message

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


With regards,
Apache Git Services

Reply via email to