On Wed, 26 May 2021 07:30:10 GMT, Peter Levart <plev...@openjdk.org> wrote:
>> Aleksei Voitylov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> fix whitespace > > src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java line 481: > >> 479: throw new Error("Maximum lock count exceeded"); >> 480: } >> 481: > > Hi Aleksei, > I know in practice this counter will never overflow, but just to be pedantic, > it would be better that you either decrement back the counter before throwing > Error or you check for overflow without incrementing it. Otherwise the lock > is left in a corrupted state since you use it like this: > > > acquireNativeLibraryLock(name); > try { > ... > } finally { > releaseNativeLibraryLock(name); > } > > ...you see, if acquire fails, it is not paired with release, which is correct > since the ReentrantLock has not been acquired, but the counter *HAS* been > incremented... Peter, the updated version checks if counter hits MAX_VALUE before incrementing. It also means the counter can't underflow, so that check is removed. ------------- PR: https://git.openjdk.java.net/jdk/pull/3976