|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
ODR_OPEN_DATABASE_RESOURCE in findbugs 1.3.8Hi,
I have a question about the detector ODR_OPEN_DATABASE_RESOURCE in findbugs 1.3.8. In the following snipped the detector creates a warning with the message that the statement on line 97 is not closed. However, the JDBC API defines that if a connection is closed than the connection object should also close the associated statements. Shouldn't the detector be adjusted to handle that case? 094 try { 095 connection = connect(); 096 097 CallableStatement statement = connection.prepareCall(query); 098 statement.execute(); 099 } 100 catch (SQLException exception) { 101 throw new DatabaseException(exception); 102 } 103 finally { 104 close(connection); 105 } Ulli _______________________________________________ Findbugs-discuss mailing list Findbugs-discuss@... https://mailman.cs.umd.edu/mailman/listinfo/findbugs-discuss |
|
|
Re: ODR_OPEN_DATABASE_RESOURCE in findbugs 1.3.8This is true if the connection is a raw connection, however it's possible that the connection came from a pool, in which case close doesn't close a connection, it just allows the pool to reuse it. So in this case you do want to close all the statements as well. And i'd go further to say, you probably should close them yourself in all cases anyway, as you don't know for sure that the driver you use tomorrow will do the right thing.
-----Original Message----- From: "Hafner Ullrich" <Ullrich.Hafner@...> Sent: Wednesday, October 7, 2009 10:56am To: Findbugs-discuss@... Subject: [FB-Discuss] ODR_OPEN_DATABASE_RESOURCE in findbugs 1.3.8 Hi, I have a question about the detector ODR_OPEN_DATABASE_RESOURCE in findbugs 1.3.8. In the following snipped the detector creates a warning with the message that the statement on line 97 is not closed. However, the JDBC API defines that if a connection is closed than the connection object should also close the associated statements. Shouldn't the detector be adjusted to handle that case? 094 try { 095 connection = connect(); 096 097 CallableStatement statement = connection.prepareCall(query); 098 statement.execute(); 099 } 100 catch (SQLException exception) { 101 throw new DatabaseException(exception); 102 } 103 finally { 104 close(connection); 105 } Ulli _______________________________________________ Findbugs-discuss mailing list Findbugs-discuss@... https://mailman.cs.umd.edu/mailman/listinfo/findbugs-discuss _______________________________________________ Findbugs-discuss mailing list Findbugs-discuss@... https://mailman.cs.umd.edu/mailman/listinfo/findbugs-discuss |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |