Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1094#discussion_r162516548
  
    --- Diff: 
exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java ---
    @@ -132,10 +132,12 @@ protected DrillConnectionImpl(DriverImpl driver, 
AvaticaFactory factory,
                 bit = new Drillbit(dConfig, serviceSet);
                 bit.run();
               } catch (final UserException e) {
    +            cleanup();
                 throw new SQLException(
                     "Failure in starting embedded Drillbit: " + e.getMessage(),
                     e);
               } catch (Exception e) {
    +            cleanup();
    --- End diff --
    
    One trick is this: used nested exceptions. The inner set "parses" the 
exception types, the outer does cleanup:
    
    ```
    try {
      try {
        // do something
      } catch (ExceptionA e) {
        // Do something
      } catch (ExceptionB e) {
        // Do something else
      ... }
     } catch (Throwable t) {
        cleanup();
        throw t;
     }
    ```


---

Reply via email to