============================================================================
JDK : java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b98)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b98, mixed mode)
DB : JavaDB
Driver : JavaDB
Platform[s] : All
============================================================================
The methods on query object is invoked by proxy and there is loose check on method called having "close" in its name. Since this check is loose, even if query method contains "close" in its string, the query object will be closed. This is a serious issue.
EXCEPTION:
----------
Trans 1 is open
Trans 2 is open
Exception in thread "main" java.sql.SQLRuntimeException: Cannot run update query
at com.sun.sql.QueryObject$2.run(QueryObject.java:252)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.sql.QueryObject.invoke(QueryObject.java:245)
at $Proxy0.closeTransactions(Unknown Source)
at EODCloseBug.main(EODCloseBug.java:49)
Caused by: java.sql.SQLException: Method called when Object has been closed
at com.sun.sql.QueryObject.getUpdateImpl(QueryObject.java:418)
at com.sun.sql.QueryObject.access$100(QueryObject.java:26)
at com.sun.sql.QueryObject$2.run(QueryObject.java:250)
... 4 more
SOURCE:
-------
import java.sql.*;
public class EODCloseBug
{
static public class Trans {
public int id;
public int closed;
public String toString() {
return "Trans " + id + (closed==1?" is closed":" is open");
}
}
interface TransQueryObject extends BaseQuery {
@java.sql.Update(sql="create table trans (id integer, closed integer)")
int createTable();
@java.sql.Update(sql="update trans set closed=1")
int closeTransactions();
@java.sql.Update(sql="insert into trans values(?1,?2)")
int insertTrans(int id, int status);
@Select(sql="select * from trans")
DataSet<Trans> getTransactions();
}
static public void main(String []args)
throws Exception
{
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
String url = "jdbc:derby:/export/home/tmp/DB/eod;create=true";
Connection conn = DriverManager.getConnection(url);
TransQueryObject pqo = conn.createQueryObject(TransQueryObject.class);
pqo.createTable();
pqo.insertTrans(1,0);
pqo.insertTrans(2,0);
DataSet<Trans> dsp = pqo.getTransactions();
System.out.println("------------------------");
for (Trans p: dsp) {
System.out.println(" " + p);
}
pqo.closeTransactions();
dsp = pqo.getTransactions();
System.out.println("------------------------");
for (Trans p: dsp) {
System.out.println(" " + p);
}
dsp.close();
pqo.close();
}
}
============================================================================
JDK : java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b98)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b98, mixed mode)
DB : JavaDB
Driver : JavaDB
Platform[s] : All
============================================================================
The methods on query object is invoked by proxy and there is loose check on method called having "close" in its name. Since this check is loose, even if query method contains "close" in its string, the query object will be closed. This is a serious issue.
EXCEPTION:
----------
Trans 1 is open
Trans 2 is open
Exception in thread "main" java.sql.SQLRuntimeException: Cannot run update query
at com.sun.sql.QueryObject$2.run(QueryObject.java:252)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.sql.QueryObject.invoke(QueryObject.java:245)
at $Proxy0.closeTransactions(Unknown Source)
at EODCloseBug.main(EODCloseBug.java:49)
Caused by: java.sql.SQLException: Method called when Object has been closed
at com.sun.sql.QueryObject.getUpdateImpl(QueryObject.java:418)
at com.sun.sql.QueryObject.access$100(QueryObject.java:26)
at com.sun.sql.QueryObject$2.run(QueryObject.java:250)
... 4 more
SOURCE:
-------
import java.sql.*;
public class EODCloseBug
{
static public class Trans {
public int id;
public int closed;
public String toString() {
return "Trans " + id + (closed==1?" is closed":" is open");
}
}
interface TransQueryObject extends BaseQuery {
@java.sql.Update(sql="create table trans (id integer, closed integer)")
int createTable();
@java.sql.Update(sql="update trans set closed=1")
int closeTransactions();
@java.sql.Update(sql="insert into trans values(?1,?2)")
int insertTrans(int id, int status);
@Select(sql="select * from trans")
DataSet<Trans> getTransactions();
}
static public void main(String []args)
throws Exception
{
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
String url = "jdbc:derby:/export/home/tmp/DB/eod;create=true";
Connection conn = DriverManager.getConnection(url);
TransQueryObject pqo = conn.createQueryObject(TransQueryObject.class);
pqo.createTable();
pqo.insertTrans(1,0);
pqo.insertTrans(2,0);
DataSet<Trans> dsp = pqo.getTransactions();
System.out.println("------------------------");
for (Trans p: dsp) {
System.out.println(" " + p);
}
pqo.closeTransactions();
dsp = pqo.getTransactions();
System.out.println("------------------------");
for (Trans p: dsp) {
System.out.println(" " + p);
}
dsp.close();
pqo.close();
}
}
JDK : java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b98)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b98, mixed mode)
DB : JavaDB
Driver : JavaDB
Platform[s] : All
============================================================================
The methods on query object is invoked by proxy and there is loose check on method called having "close" in its name. Since this check is loose, even if query method contains "close" in its string, the query object will be closed. This is a serious issue.
EXCEPTION:
----------
Trans 1 is open
Trans 2 is open
Exception in thread "main" java.sql.SQLRuntimeException: Cannot run update query
at com.sun.sql.QueryObject$2.run(QueryObject.java:252)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.sql.QueryObject.invoke(QueryObject.java:245)
at $Proxy0.closeTransactions(Unknown Source)
at EODCloseBug.main(EODCloseBug.java:49)
Caused by: java.sql.SQLException: Method called when Object has been closed
at com.sun.sql.QueryObject.getUpdateImpl(QueryObject.java:418)
at com.sun.sql.QueryObject.access$100(QueryObject.java:26)
at com.sun.sql.QueryObject$2.run(QueryObject.java:250)
... 4 more
SOURCE:
-------
import java.sql.*;
public class EODCloseBug
{
static public class Trans {
public int id;
public int closed;
public String toString() {
return "Trans " + id + (closed==1?" is closed":" is open");
}
}
interface TransQueryObject extends BaseQuery {
@java.sql.Update(sql="create table trans (id integer, closed integer)")
int createTable();
@java.sql.Update(sql="update trans set closed=1")
int closeTransactions();
@java.sql.Update(sql="insert into trans values(?1,?2)")
int insertTrans(int id, int status);
@Select(sql="select * from trans")
DataSet<Trans> getTransactions();
}
static public void main(String []args)
throws Exception
{
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
String url = "jdbc:derby:/export/home/tmp/DB/eod;create=true";
Connection conn = DriverManager.getConnection(url);
TransQueryObject pqo = conn.createQueryObject(TransQueryObject.class);
pqo.createTable();
pqo.insertTrans(1,0);
pqo.insertTrans(2,0);
DataSet<Trans> dsp = pqo.getTransactions();
System.out.println("------------------------");
for (Trans p: dsp) {
System.out.println(" " + p);
}
pqo.closeTransactions();
dsp = pqo.getTransactions();
System.out.println("------------------------");
for (Trans p: dsp) {
System.out.println(" " + p);
}
dsp.close();
pqo.close();
}
}
============================================================================
JDK : java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b98)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b98, mixed mode)
DB : JavaDB
Driver : JavaDB
Platform[s] : All
============================================================================
The methods on query object is invoked by proxy and there is loose check on method called having "close" in its name. Since this check is loose, even if query method contains "close" in its string, the query object will be closed. This is a serious issue.
EXCEPTION:
----------
Trans 1 is open
Trans 2 is open
Exception in thread "main" java.sql.SQLRuntimeException: Cannot run update query
at com.sun.sql.QueryObject$2.run(QueryObject.java:252)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.sql.QueryObject.invoke(QueryObject.java:245)
at $Proxy0.closeTransactions(Unknown Source)
at EODCloseBug.main(EODCloseBug.java:49)
Caused by: java.sql.SQLException: Method called when Object has been closed
at com.sun.sql.QueryObject.getUpdateImpl(QueryObject.java:418)
at com.sun.sql.QueryObject.access$100(QueryObject.java:26)
at com.sun.sql.QueryObject$2.run(QueryObject.java:250)
... 4 more
SOURCE:
-------
import java.sql.*;
public class EODCloseBug
{
static public class Trans {
public int id;
public int closed;
public String toString() {
return "Trans " + id + (closed==1?" is closed":" is open");
}
}
interface TransQueryObject extends BaseQuery {
@java.sql.Update(sql="create table trans (id integer, closed integer)")
int createTable();
@java.sql.Update(sql="update trans set closed=1")
int closeTransactions();
@java.sql.Update(sql="insert into trans values(?1,?2)")
int insertTrans(int id, int status);
@Select(sql="select * from trans")
DataSet<Trans> getTransactions();
}
static public void main(String []args)
throws Exception
{
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
String url = "jdbc:derby:/export/home/tmp/DB/eod;create=true";
Connection conn = DriverManager.getConnection(url);
TransQueryObject pqo = conn.createQueryObject(TransQueryObject.class);
pqo.createTable();
pqo.insertTrans(1,0);
pqo.insertTrans(2,0);
DataSet<Trans> dsp = pqo.getTransactions();
System.out.println("------------------------");
for (Trans p: dsp) {
System.out.println(" " + p);
}
pqo.closeTransactions();
dsp = pqo.getTransactions();
System.out.println("------------------------");
for (Trans p: dsp) {
System.out.println(" " + p);
}
dsp.close();
pqo.close();
}
}