Keep the ECOD read lock balanced when loading fails - #1150
Open
aalhossary wants to merge 1 commit into
Open
Conversation
getDomainsForPdb and getAllDomains release the read lock inside their try block, so that the loader they call can take the write lock, and re-acquire it afterwards. When that loader throws, the re-acquisition never happens, and the outer finally unlocks a lock the thread no longer holds. The resulting IllegalMonitorStateException is thrown from a finally block, so it supersedes the IOException that actually caused the failure. Last night's nightly showed this: one upstream change - ECOD now answers with a 308 that HttpURLConnection will not follow - produced eight failures with three different-looking causes, only three of which named the redirect. Re-acquiring in a finally of its own keeps the lock balanced on both paths, so the original exception propagates intact.
aalhossary
added a commit
to aalhossary/biojava
that referenced
this pull request
Aug 30, 2026
Covers what is merged since 7.2.6 and what is open and expected to land: the download and checksum work, the CATH and ECOD fixes, the contact and ASA performance tweaks, electron density, and the JUnit 5 migration. Five entries are for pull requests that are still open - biojava#1134, biojava#1147, biojava#1148, biojava#1150 and biojava#1151 - and should be checked against what actually merged before the release is tagged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getDomainsForPdbandgetAllDomainsrelease the read lock inside theirtryblock — so the loader they call can take the write lock — and re-acquire it immediately afterwards:When the loader throws, the re-acquisition is skipped, and the outer
finallyunlocks a lock the thread no longer holds.IllegalMonitorStateExceptionis then thrown from a finally block, so it supersedes theIOExceptionthat actually caused the failure.Why it matters, concretely
Last night's nightly (
33303708377) is a clean demonstration. One upstream change — ECOD now answershttp://prodata.swmed.edu/ecod/distributions/…with a 308 thatHttpURLConnectionwill not follow, see #1149 — produced eight failures wearing three different faces:Only the first names the cause. The second is this bug. Diagnosing it meant reading past the noise to find the three tests that had told the truth.
The fix
Re-acquire in a
finallyof its own, so the lock is balanced on both paths and the original exception propagates intact:Six lines in each of the two methods, no behaviour change on the success path. The other four read-lock sites in the class are already balanced — they lock, return, and unlock in a
finallywithout releasing in between — so they are untouched.Scope
This does not fix the ECOD download itself; that is #1149, and it needs
FileDownloadUtilsto follow the redirects the JDK declines. This only stops a failing load from disguising its own cause.The third face above —
EcodFactoryhanding backnullafter swallowing the error — is the same family of masking and is also not addressed here.Testing
mvn test -pl biojava-structure -Dtest=EcodParserTest— green, and the class compiles unchanged otherwise. The failure path is not covered by an automated test: reproducing it needs a download that throws, which today means either the network being down or ECOD still being broken. If you would like it pinned, the natural way is a small unit test that injects a failing loader, which would mean making the loader overridable — happy to add that if you think it is worth the seam.