Opened 17 years ago
Closed 17 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: |
Description
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:
java.lang.NullPointerException at net.sf.basedb.core.BasicBatcher.<init>(BasicBatcher.java:149) at net.sf.basedb.core.RawDataBatcher.<init>(RawDataBatcher.java:172) at net.sf.basedb.core.RawDataBatcher.getNew(RawDataBatcher.java:103) at net.sf.basedb.core.RawBioAssay.onBeforeCommit(RawBioAssay.java:296) at net.sf.basedb.core.DbControl.commit(DbControl.java:372) at net.sf.basedb.core.Trashcan.delete(Trashcan.java:229)
But, before the failure the following code has been executed:
AbstractBatcher(DbControl dc) { .... dc.addBatcher(this); }
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:
java.lang.NullPointerException at net.sf.basedb.core.RawDataBatcher.onBeforeClose(RawDataBatcher.java:319) at net.sf.basedb.core.AbstractBatcher.close(AbstractBatcher.java:122) at net.sf.basedb.core.DbControl.rollback(DbControl.java:269) at net.sf.basedb.core.DbControl.close(DbControl.java:237) at net.sf.basedb.core.Trashcan.delete(Trashcan.java:233)
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 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(In [3747]) Fixes #766: Batchers may be registered with a DbControl even if constructor throw an exception