Habibi's code example, locking and unlocking records
posted 11 years ago
Hi, I'm studying for the SCJD exam and looking through the code examples from Habibi's book, namely the DVDDbAdapter class. The modify DVD method goes something like this:
My question is, suppose the call to db.modifyDVD (fourth line) throws an exception. Does that mean the line which releases this DVD will not be called? My concern is that in the case of an exception (this method may also throw IOException), this DVD will never be released, and no threads from this point on can ever reserve it.
Would it be more correct to put the release code in a finally block at the end? Thanks for any info.