@@ -177,23 +177,8 @@ LockedFileChannel acquireWrite() throws IOException {
177177 }
178178
179179 // We have a WRITE ChannelLock.
180- // Try to open a FileChannel.
181- final FileChannel channel ;
182- try {
183- channel = FileChannel .open (path , StandardOpenOption .READ , StandardOpenOption .WRITE , StandardOpenOption .CREATE );
184- } catch (IOException e ) {
185- // Something went wrong. Back off.
186- try {
187- channelLock .close ();
188- } finally {
189- channelLockMutex .release ();
190- }
191- throw e ;
192- }
193-
194- // We have a FileChannel.
195180 // Create a LockedFileChannel that will releaseWrite() when it is closed.
196- return new LockedFileChannel (channel , this ::releaseWrite );
181+ return new LockedFileChannel (channelLock . getChannel () , this ::releaseWrite );
197182 } catch (InterruptedException e ) {
198183 throw new IOException (e );
199184 }
@@ -214,22 +199,8 @@ LockedFileChannel tryAcquireWrite() {
214199 }
215200
216201 // We have a WRITE ChannelLock.
217- // Try to open a FileChannel.
218- final FileChannel channel ;
219- try {
220- channel = FileChannel .open (path , StandardOpenOption .READ , StandardOpenOption .WRITE , StandardOpenOption .CREATE );
221- } catch (IOException e ) {
222- // Something went wrong. Back off.
223- try {
224- releaseChannelLock ();
225- } catch (IOException ignored ) {
226- }
227- return null ;
228- }
229-
230- // We have a FileChannel.
231202 // Create a LockedFileChannel that will releaseWrite() when it is closed.
232- return new LockedFileChannel (channel , this ::releaseWrite );
203+ return new LockedFileChannel (channelLock . getChannel () , this ::releaseWrite );
233204 }
234205
235206 void releaseWrite () throws IOException {
0 commit comments