Tibor17 commented on a change in pull request #49: [MNG-2802] Concurrent-safe 
access to local Maven repository
URL: https://github.com/apache/maven-wagon/pull/49#discussion_r303271824
 
 

 ##########
 File path: 
wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/WaitingLockableFileWriter.java
 ##########
 @@ -0,0 +1,301 @@
+package org.apache.maven.wagon.providers.file;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.io.Charsets;
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * CHECKSTYLE_OFF: LineLength
+ * Adapted from commons-io LockableFileWriter
+ * 
https://github.com/apache/commons-io/blob/58b0f795b31482daa6bb5473a8b2c398e029f5fb/src/main/java/org/apache/commons/io/output/LockableFileWriter.java
+ * licenced under apache-2.0
+ *
+ * Aside from some clean-up of not used parts, the main difference is that we 
can optionally wait for a file lock.
+ *
+ * @author <a href="mailto:erikha...@gmail.com";>Erik HÃ¥kansson</a>
+ * CHECKSTYLE_ON: LineLength
+ */
+public class WaitingLockableFileWriter extends Writer
+{
+    // Cannot extend ProxyWriter, as requires writer to be
+    // known when super() is called
+
+    /**
+     * The extension for the lock file.
+     */
+    private static final String LCK = ".lck";
+
+    /**
+     * The writer to decorate.
+     */
+    private final Writer out;
+    /**
+     * The lock file.
+     */
+    private final File lockFile;
+
+    /**
+     * Constructs a WaitingLockableFileWriter with a file encoding.
+     *
+     * @param file        the file to write to, not null
+     * @param encoding    the encoding to use, null means platform default
+     * @param append      true if content should be appended, false to 
overwrite
+     * @param lockDir     the directory in which the lock file should be held
+     * @param timeout     how long to wait for a lock if file is already locked
+     * @param timeoutUnit unit of timeout
+     * @param wait        should we wait while trying to obtain lock
+     * @throws NullPointerException if the file is null
+     * @throws IOException          in case of an I/O error
+     * @since 2.3
+     */
+    public WaitingLockableFileWriter( File file, final Charset encoding, final 
boolean append, String lockDir,
+                                      long timeout, TimeUnit timeoutUnit, 
boolean wait ) throws IOException
+    {
+        super();
 
 Review comment:
   super() is added by compiler, so it can be avoided in code.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to