[jira] [Comment Edited] (MRESOLVER-372) Download fails if file is currently in use under windows

2023-11-15 Thread Tamas Cservenak (Jira)


[ 
https://issues.apache.org/jira/browse/MRESOLVER-372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17786522#comment-17786522
 ] 

Tamas Cservenak edited comment on MRESOLVER-372 at 11/15/23 10:15 PM:
--

Just to shed some light what code does:
* you have some new content (ie. downloaded or built, so resolve or install 
case)
* the target file may or may not exists
* the code writes to tmp/random file _in same directory_ (so it is not cross FS 
or whatever atomic move even, it is happening within same god damn directory)
* once the file is written to tmp file, atomic rename to "final file" is done

The reason of this is to prevent other processes (maybe unaware of maven 3.9 
locking) to be able to read "partially written" (ie. slow download) files, 
basically this is what "atomic move" is about, and why it was invented in the 
first place. 


was (Author: cstamas):
Just to shed some light what code does:
* you have some new content (ie. downloaded or built, so resolve or install 
case)
* the target file may or may not exists
* the code writes to tmp/random file _in same directory_ (so it is not cross FS 
or whatever atomic move even, it is happening within same god damn directory)
* once the file is written to tmp file, atomic rename to "final file" is done

> Download fails if file is currently in use under windows
> 
>
> Key: MRESOLVER-372
> URL: https://issues.apache.org/jira/browse/MRESOLVER-372
> Project: Maven Resolver
>  Issue Type: Bug
>  Components: Resolver
>Reporter: Christoph Läubrich
>Priority: Major
> Fix For: 2.0.0, 1.9.17
>
>
> With the new file-locking in maven-resolver there is a problem under windows 
> if the file is currently used by another process (this can for example happen 
> in an IDE ...) and resolver likes to move the file:
>  
> {code:java}
>  Caused by: java.nio.file.AccessDeniedException: 
> xxx-SNAPSHOT.jar.15463549870494779429.tmp -> -SNAPSHOT.jar
>         at 
> java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
>         at 
> java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
>         at java.base/sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:317)
>         at 
> java.base/sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:293)
>         at java.base/java.nio.file.Files.move(Files.java:1432)
>         at org.eclipse.aether.util.FileUtils$2.move(FileUtils.java:108)
>         at 
> org.eclipse.aether.internal.impl.DefaultFileProcessor.copy(DefaultFileProcessor.java:96)
>         at 
> org.eclipse.aether.internal.impl.DefaultFileProcessor.copy(DefaultFileProcessor.java:88)
>         at 
> org.eclipse.aether.internal.impl.DefaultArtifactResolver.getFile(DefaultArtifactResolver.java:490)
>         ... 30 more{code}
>  
> My suggestion would be that resolver simply uses the temp file if it can't be 
> moved to final location and marks it as delete on exit. Even though this is 
> not optimal, it at least ensures the the build does not fail to the cost that 
> next time the file needs to be downloaded again.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (MRESOLVER-372) Download fails if file is currently in use under windows

2023-07-12 Thread Delany (Jira)


[ 
https://issues.apache.org/jira/browse/MRESOLVER-372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17742314#comment-17742314
 ] 

Delany edited comment on MRESOLVER-372 at 7/12/23 8:19 AM:
---

Can happen at the end of a large deployAtEnd build (on CI machine)
{code:java}
09:46:47  [INFO] Retrying deployment attempt 3 of 3
...
09:50:10  Caused by: java.nio.file.AccessDeniedException: 
maven-metadata--snapshots.xml.12223878285861141839.tmp -> 
maven-metadata--snapshots.xml
09:50:10      at sun.nio.fs.WindowsException.translateToIOException 
(WindowsException.java:89)
09:50:10      at sun.nio.fs.WindowsException.rethrowAsIOException 
(WindowsException.java:103)
09:50:10      at sun.nio.fs.WindowsFileCopy.move (WindowsFileCopy.java:309)
09:50:10      at sun.nio.fs.WindowsFileSystemProvider.move 
(WindowsFileSystemProvider.java:292)
09:50:10      at java.nio.file.Files.move (Files.java:1422)
09:50:10      at org.eclipse.aether.util.FileUtils$2.move (FileUtils.java:108)
09:50:10      at 
org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask
 (BasicRepositoryConnector.java:500)
09:50:10      at 
org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run 
(BasicRepositoryConnector.java:414)
09:50:10      at 
org.eclipse.aether.connector.basic.BasicRepositoryConnector.get 
(BasicRepositoryConnector.java:215)
09:50:10      at org.eclipse.aether.internal.impl.DefaultDeployer.upload 
(DefaultDeployer.java:367)
09:50:10      at org.eclipse.aether.internal.impl.DefaultDeployer.deploy 
(DefaultDeployer.java:238)
09:50:10      at org.eclipse.aether.internal.impl.DefaultDeployer.deploy 
(DefaultDeployer.java:201)
09:50:10      at 
org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy 
(DefaultRepositorySystem.java:392)
09:50:10      at org.apache.maven.plugins.deploy.AbstractDeployMojo.deploy 
(AbstractDeployMojo.java:139)
09:50:10      at org.apache.maven.plugins.deploy.DeployMojo.deployAllAtOnce 
(DeployMojo.java:251)
09:50:10      at org.apache.maven.plugins.deploy.DeployMojo.execute 
(DeployMojo.java:218) {code}
Maven 3.9.3

-Daether.syncContext.named.factory=file-lock
-Daether.syncContext.named.nameMapper=file-gav


was (Author: delany):
Can happen at the end of a large deployAtEnd build
{code:java}
09:46:47  [INFO] Retrying deployment attempt 3 of 3
...
09:50:10  Caused by: java.nio.file.AccessDeniedException: 
maven-metadata--snapshots.xml.12223878285861141839.tmp -> 
maven-metadata--snapshots.xml
09:50:10      at sun.nio.fs.WindowsException.translateToIOException 
(WindowsException.java:89)
09:50:10      at sun.nio.fs.WindowsException.rethrowAsIOException 
(WindowsException.java:103)
09:50:10      at sun.nio.fs.WindowsFileCopy.move (WindowsFileCopy.java:309)
09:50:10      at sun.nio.fs.WindowsFileSystemProvider.move 
(WindowsFileSystemProvider.java:292)
09:50:10      at java.nio.file.Files.move (Files.java:1422)
09:50:10      at org.eclipse.aether.util.FileUtils$2.move (FileUtils.java:108)
09:50:10      at 
org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask
 (BasicRepositoryConnector.java:500)
09:50:10      at 
org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run 
(BasicRepositoryConnector.java:414)
09:50:10      at 
org.eclipse.aether.connector.basic.BasicRepositoryConnector.get 
(BasicRepositoryConnector.java:215)
09:50:10      at org.eclipse.aether.internal.impl.DefaultDeployer.upload 
(DefaultDeployer.java:367)
09:50:10      at org.eclipse.aether.internal.impl.DefaultDeployer.deploy 
(DefaultDeployer.java:238)
09:50:10      at org.eclipse.aether.internal.impl.DefaultDeployer.deploy 
(DefaultDeployer.java:201)
09:50:10      at 
org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy 
(DefaultRepositorySystem.java:392)
09:50:10      at org.apache.maven.plugins.deploy.AbstractDeployMojo.deploy 
(AbstractDeployMojo.java:139)
09:50:10      at org.apache.maven.plugins.deploy.DeployMojo.deployAllAtOnce 
(DeployMojo.java:251)
09:50:10      at org.apache.maven.plugins.deploy.DeployMojo.execute 
(DeployMojo.java:218) {code}
Maven 3.9.3

-Daether.syncContext.named.factory=file-lock
-Daether.syncContext.named.nameMapper=file-gav

> Download fails if file is currently in use under windows
> 
>
> Key: MRESOLVER-372
> URL: https://issues.apache.org/jira/browse/MRESOLVER-372
> Project: Maven Resolver
>  Issue Type: Bug
>Reporter: Christoph Läubrich
>Priority: Major
>
> With the new file-locking in maven-resolver there is a problem under windows 
> if the file is currently used by another process (this can for example happen 
> in an IDE ...) and resolver likes to move the file:
>  
> {code:java}
>  Caused by: java.nio.file.AccessDeniedException: 
>