Gentlemen,
I beg your pardon for incomplete problem description.
On AIX 5.1, IBM Java 1.3.1 I'm using pg74jdbc3.jar dated 24.12.03.
We have a flaw in a legacy program: it calls Statement.close() inside
try() and in finally{} - thus, two times.
On doing that, I get:
java.sql.SQLException: Statement has been closed
at org.postgresql.jdbc2.optional.PooledConnectionImpl$StatementHandler.invoke(
PooledConnectionImpl.java(Compiled Code))
at $Proxy1.close(Unknown Source)(Compiled Code)
at SomeUserClass.someMethod(Something.java:1345)
As JDK java.sql.Statement.close() documentation specifies, calling
Statement.close() on already close()d statement should have no effect.
It's the way Oracle and MS SQL drivers behave, but PG driver throws
this exception.
A pity, I cannot reproduce this statement on my working desk on
Windows XP + Sun Java 1.3.1_02. If I get the possibility to debug on
AIX, I can report more precisely.
Looks like it's postgresql\jdbc2\optional\PooledConnectionImpl.java,
lines ~365:
// All the rest is from the Statement interface
if (st == null || con.isClosed())
{
throw new SQLException("Statement has been closed");
}
if (method.getName().equals("close"))
{
try {
st.close();
} finally {
con = null;
st = null;
return null;
}
}
As for me, this should look like:
// All the rest is from the Statement interface
if (method.getName().equals("close"))
{
try {
if (st != null && !con.isClosed()) st.close();
} finally {
con = null;
st = null;
return null;
}
}
if (st == null || con.isClosed())
{
throw new SQLException("Statement has been closed");
}
My question is: is it a known bug, an intended feature, or an
OS/JDK-specific bug that was not known before? What's wrong with my
suggestion?
Thank you.
--
Best regards,
Victor Sergienko