[ https://issues.apache.org/jira/browse/MNG-2802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16591349#comment-16591349 ]
ASF GitHub Bot commented on MNG-2802: ------------------------------------- erikhakansson 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_r212562988 ########## File path: wagon-providers/wagon-file-test/src/main/java/org/apache/maven/wagon/providers/file/LazyLockableFileOutputStreamTestDriver.java ########## @@ -0,0 +1,75 @@ +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 java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.util.concurrent.TimeUnit; + +/** + * Test driver for LazyLockableFileOutputStreamIntegrationTest + */ +public class LazyLockableFileOutputStreamTestDriver +{ + public static void main( String[] args ) throws Exception + { + File file = new File( args[0] ); + long timeout = Long.parseLong( args[1] ); + long startTime = System.currentTimeMillis(); + OutputStream outputStream = new LazyLockableFileOutputStream( file, timeout, TimeUnit.SECONDS ); + try + { + outputStream.write( 1 ); + } + catch ( IOException e ) + { + if ( e.getMessage().equals( "Can't write file, lock " + file.getAbsolutePath() + ".lck exists" ) ) + { + System.out.println( "ready" ); + // CHECKSTYLE_OFF: MagicNumber + System.exit( 126 ); + // CHECKSTYLE_ON: MagicNumber + } + else if ( e.getMessage().equals( "Failed to create lockfile " + file.getAbsolutePath() + + ".lck after waiting " + timeout + " seconds. File already exists." ) ) + { + long diff = System.currentTimeMillis() - startTime; + if ( diff < TimeUnit.SECONDS.toMillis( timeout ) ) + { + throw new Exception( "We were supposed to wait for " + timeout + + " seconds, but Exception came early at " + diff + " milliseconds." ); + } + System.out.println( "ready" ); + // CHECKSTYLE_OFF: MagicNumber + System.exit( 127 ); Review comment: ping @olamy what do you think? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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 > Concurrent-safe access to local Maven repository > ------------------------------------------------ > > Key: MNG-2802 > URL: https://issues.apache.org/jira/browse/MNG-2802 > Project: Maven > Issue Type: Improvement > Components: Artifacts and Repositories > Reporter: Stepan Roh > Assignee: John Casey > Priority: Major > Fix For: Issues to be reviewed for 3.x > > > It seems that access to local Maven repository is not concurrent-safe that is > multiple Mavens running in parallel may damage contents of local Maven > repository. It would be a nice improvement, because sharing of local > repository will lower the need for contacting any other repository. I know > that Maven proxy can be used, but that adds another layer which may > unnecessarily stress the machine it runs on. > *NOTE:* > http://takari.io/book/30-team-maven.html#concurrent-safe-local-repository is > a Takari Extension for Apache Maven that introduces a concurrent-safe > local-repository. -- This message was sent by Atlassian JIRA (v7.6.3#76005)