paul-rogers opened a new issue, #12684:
URL: https://github.com/apache/druid/issues/12684

   ### Affected Version
   
   Latest `master` version.
   
   ### Description
   
   According to the [JDBC 4.1 
Spec](https://download.oracle.com/otn-pub/jcp/jdbc-4_1-mrel-spec/jdbc4.1-fr-spec.pdf?AuthParam=1655858260_d6388aeec9aeb8e5616d221749b1ff71),
 a JDBC `Statement` is closed when:
   
   > An application calls the method Statement.close to indicate that it has 
finished processing a statement. All Statement objects will be closed when the 
connection that created them is closed.
   
   This means that, if a statement encounters an exception, we can close the 
`ResultSet` associated with a statement, but not the statement itself. Yet, 
Druid explicitly closes statements on errors. Consider this test in ``:
   
   ```java
     @Test
     public void testNotTooManyStatementsWhenTheyThrowErrors() throws Exception
     {
       for (int i = 0; i < 50; i++) {
         Exception thrown = null;
         try {
           client.createStatement().executeQuery("SELECT SUM(nonexistent) FROM 
druid.foo");
         }
         catch (Exception e) {
           thrown = e;
         }
   
         Assert.assertNotNull(thrown);
       }
     }
   ```
   
   The only way the above could work is if `executeQuery()` closes the 
statement, which it should *not* do. The failure *can* close the associated 
`ResultSet`.
   
   The test *should* be coded as:
   
   ```java
     @Test
     public void testNotTooManyStatementsWhenClosed() throws Exception
     {
       for (int i = 0; i < 50; i++) {
         Exception thrown = null;
         try (Statement statement = client.createStatement()) {
           statement.executeQuery("SELECT SUM(nonexistent) FROM druid.foo");
         }
         catch (Exception e) {
           thrown = e;
         }
   
         Assert.assertNotNull(thrown);
       }
     }
   ```
   
   ### Solution
   
   This issue is fixed in PR #12636.
   
   


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to