This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch file-lock in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
commit 42498bed817cb1a5cbfd1fcdfcc5ad0d48321dc8 Author: Michael Osipov <[email protected]> AuthorDate: Sun Dec 12 20:02:02 2021 +0100 Improvements on FileLockNamedLockFactory * Redis-based Semaphore throws an ISE when object is not there, shouldn't this one also throw one? * Redis-based Semaphore doesn't call super destroyLock b/c it is a no-op --- .../named/providers/FileLockNamedLockFactory.java | 33 +++++++++------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/maven-resolver-named-locks/src/main/java/org/eclipse/aether/named/providers/FileLockNamedLockFactory.java b/maven-resolver-named-locks/src/main/java/org/eclipse/aether/named/providers/FileLockNamedLockFactory.java index 2ba5a1a..d2b765d 100644 --- a/maven-resolver-named-locks/src/main/java/org/eclipse/aether/named/providers/FileLockNamedLockFactory.java +++ b/maven-resolver-named-locks/src/main/java/org/eclipse/aether/named/providers/FileLockNamedLockFactory.java @@ -74,7 +74,8 @@ public class FileLockNamedLockFactory } catch ( IOException e ) { - throw new UncheckedIOException( path.toString(), e ); + throw new UncheckedIOException( "Failed to open file channel for '" + + name + "'", e ); } } ); return new FileLockNamedLock( name, fileChannel, this ); @@ -83,28 +84,20 @@ public class FileLockNamedLockFactory @Override protected void destroyLock( final String name ) { + FileChannel fileChannel = channels.remove( name ); + if ( fileChannel == null ) + { + throw new IllegalStateException( "File channel expected, but does not exist: " + name ); + } + try { - FileChannel fileChannel = channels.remove( name ); - if ( fileChannel != null ) - { - try - { - fileChannel.close(); - } - catch ( IOException e ) - { - throw new UncheckedIOException( e ); - } - } - else - { - logger.warn( "No FileChannel for lock '{}'", name ); - } + fileChannel.close(); } - finally + catch ( IOException e ) { - super.destroyLock( name ); + throw new UncheckedIOException( "Failed to close file channel for '" + + name + "'", e ); } } -} \ No newline at end of file +}
