Commit 942ca98
committed
fix(cache): extend nested-try-finally lock release to remaining AnalysisCache methods
Follow-up to 798bccf. That commit fixed UL_UNRELEASED_LOCK_EXCEPTION_PATH
in AnalysisCache.removeFile and flagged the same lock-leak pattern in
two other methods that SpotBugs did not surface (likely because they
differ subtly in what's inside the outer try body).
Both methods — storeResults (the INSERT nodes/edges path) and the
replace-with-enriched-data path — had:
} finally {
try { conn.setAutoCommit(true); } catch (SQLException ignored) {}
rwLock.writeLock().unlock();
}
If conn.setAutoCommit(true) throws anything other than SQLException
(RuntimeException or Error), execution exits the finally before
rwLock.writeLock().unlock() runs, leaving the write lock held and
freezing all subsequent cache writers.
Wrap setAutoCommit in a nested try-finally so unlock is always reached:
} finally {
try {
try { conn.setAutoCommit(true); } catch (SQLException ignored) {}
} finally {
rwLock.writeLock().unlock();
}
}
All three lock-holding paths (removeFile, storeResults, replace-with-
enriched) now share the same exception-safe pattern. mvn test -Dtest=
AnalysisCacheTest passes.1 parent 7038bd9 commit 942ca98
1 file changed
Lines changed: 18 additions & 6 deletions
Lines changed: 18 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
376 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
377 | 384 | | |
378 | | - | |
379 | 385 | | |
380 | 386 | | |
381 | 387 | | |
| |||
605 | 611 | | |
606 | 612 | | |
607 | 613 | | |
608 | | - | |
609 | | - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
610 | 623 | | |
611 | | - | |
612 | 624 | | |
613 | 625 | | |
614 | 626 | | |
| |||
0 commit comments