Subject | Re: [Firebird-Java] Re: NPE in isc_start_transaction (db.out.writeInt(op_transaction)) |
---|---|
Author | Roman Rokytskyy |
Post date | 2004-12-09T15:11:02Z |
Hi Josef,
acceptable.
a) you have to add method boolean isValid() and invalidate() to
isc_tr_handle interface and to the implementations.
b) in the isc_db_handle_impl.invalidate() you have to loop through all
"registered" tr handles and invalidate them before setting out to null. Also
care should be taken in regard to synchronization (I would use
synchronized(tr_handle))
c) all calls that peform something with the database should be converted
into
synchronized(currentTr) {
if (!currentTr.isValid())
throw something;
....
}
d) FBManagedConnectionFactory.getTrHandleForXid(...) should be changed to
check if tr_handle is still valid, and return null if not.
The rest should happen automatically.
Now David Jencks should confirm that this is correct solution in regard to
XA protocol. Most likely driver should throw an error in d) telling the
resource manager that transaction is marked for rollback only if found tr
handle is no longer valid.
getTrHandleForXid (this would mean - I have no idea about the passed Xid).
Roman
> 1) Data is inserted by a webservice, which is called from anotherOk. But that is also application problem. So the fix is more or less
> application. If an exception occurs, then this exception is logged,
> but the app doesn't try to send the data again --> therefore the
> record is not in the database (lost).
acceptable.
> 2) What would be the correct place for fix 1?As I wrote:
> Three lines below the NPE happens.
a) you have to add method boolean isValid() and invalidate() to
isc_tr_handle interface and to the implementations.
b) in the isc_db_handle_impl.invalidate() you have to loop through all
"registered" tr handles and invalidate them before setting out to null. Also
care should be taken in regard to synchronization (I would use
synchronized(tr_handle))
c) all calls that peform something with the database should be converted
into
synchronized(currentTr) {
if (!currentTr.isValid())
throw something;
....
}
d) FBManagedConnectionFactory.getTrHandleForXid(...) should be changed to
check if tr_handle is still valid, and return null if not.
The rest should happen automatically.
Now David Jencks should confirm that this is correct solution in regard to
XA protocol. Most likely driver should throw an error in d) telling the
resource manager that transaction is marked for rollback only if found tr
handle is no longer valid.
> 3) What would be a correct method to get a new db-Handle withinAs I wrote, should happen automatically as soon as you return null from
> isc_StartTransaction if db.out == null?
getTrHandleForXid (this would mean - I have no idea about the passed Xid).
Roman