William1104 commented on a change in pull request #24747: 
[SPARK-27772][SQL][TEST] Refactor SQLTestUtils to use `tryWithSafeFinally`
URL: https://github.com/apache/spark/pull/24747#discussion_r289661864
 
 

 ##########
 File path: sql/core/src/test/scala/org/apache/spark/sql/test/SQLTestUtils.scala
 ##########
 @@ -268,11 +270,13 @@ private[sql] trait SQLTestUtilsBase
    * Drops global temporary view `viewNames` after calling `f`.
    */
   protected def withGlobalTempView(viewNames: String*)(f: => Unit): Unit = {
-    try f finally {
-      // If the test failed part way, we don't want to mask the failure by 
failing to remove
-      // global temp views that never got created.
-      try viewNames.foreach(spark.catalog.dropGlobalTempView) catch {
-        case _: NoSuchTableException =>
+    Utils.tryWithSafeFinally(f) {
+      viewNames.foreach { viewName =>
+        try spark.catalog.dropGlobalTempView(viewName) catch {
+          // If the test failed part way, we don't want to mask the failure by 
failing to remove
+          // temp views that never got created.
 
 Review comment:
   Thanks. It is recovered.

----------------------------------------------------------------
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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to