I have been
testing my locking algorithm and have some questions regarding handling of exceptions within a locked section.
The design uses an Adapter class on top of Data. Data contains a cached list of records, and recNo (position in file) is used as the primary key. Each client has its own copy of Data.
The following code sample shows the bookContractor() method which performs the following:
* lock
* Checks to make sure record is not already booked.
* Updates/books record (More file IO)
* unlock
If the record is already booked, the unlock() method is called and an exception is thrown.
However, my question regards what should happen with IO error which is harder to simulate in testing. If an IO exception is not caught, the unlock method will never be called. The workaround that I see is to put the IO calls in a try catch block, which will catch the IOException, call unlock(), and then rethrow the exception.
Any insight appreciated.
[ July 06, 2005: Message edited by: Jack Gold ]
[ July 06, 2005: Message edited by: Jack Gold ]
[ July 06, 2005: Message edited by: Jack Gold ]
[ July 06, 2005: Message edited by: Jack Gold ]