Opened 16 years ago

Closed 16 years ago

#766 closed defect (fixed)

Batchers may be registered with a DbControl even if constructor throw an exception

Reported by: Nicklas Nordborg Owned by: Nicklas Nordborg
Priority: critical Milestone: BASE 2.4.2
Component: core Version:
Keywords: Cc:


This issue is related to #765. What is happening there is that a batcher is created to try to delete raw data for an Affymetrix raw bioassay. Since it is not stored in database the creation of the batcher will fail:

	at net.sf.basedb.core.BasicBatcher.<init>(
	at net.sf.basedb.core.RawDataBatcher.<init>(
	at net.sf.basedb.core.RawDataBatcher.getNew(
	at net.sf.basedb.core.RawBioAssay.onBeforeCommit(
	at net.sf.basedb.core.DbControl.commit(
	at net.sf.basedb.core.Trashcan.delete(

But, before the failure the following code has been executed:

AbstractBatcher(DbControl dc)

Thus, the DbControl? has a link to "half-constructed" object. Due to the NullPointerException? the transaction is beeing rollbacked. The rollback code is calling close() on all registered batchers, which generates the exception we see in ticket #765:

	at net.sf.basedb.core.RawDataBatcher.onBeforeClose(
	at net.sf.basedb.core.AbstractBatcher.close(
	at net.sf.basedb.core.DbControl.rollback(
	at net.sf.basedb.core.DbControl.close(
	at net.sf.basedb.core.Trashcan.delete(

This exception happens because not all fields get initialized due to the first exception. The safest way to solve this is to not register a batcher with the DbControl? until the object has been completely constructed. This requires that we move the call to dc.addBatcher(this) to some other (non-central) place.

Change History (2)

comment:1 Changed 16 years ago by Nicklas Nordborg

Owner: changed from everyone to Nicklas Nordborg
Status: newassigned

comment:2 Changed 16 years ago by Nicklas Nordborg

Resolution: fixed
Status: assignedclosed

(In [3747]) Fixes #766: Batchers may be registered with a DbControl? even if constructor throw an exception

Note: See TracTickets for help on using tickets.