Skip to content

indexer-cli throws java.nio.file.FileAlreadyExistsException on re-run with same index dir #720

Description

@tobias

Affected version

7.1.6

Bug description

When running the CLI with:

java -jar indexer-cli-7.1.6-cli.jar \
    --name clojars \
    --type min \
    --index ./index \
    --destination ./repo/.index \
    --repository ./repo \
    --checksums \
    --quiet \
    --chunks \
    --keep 50

It runs successfully on the first run (when ./index is empty). On a subsequent run, it fails with:

java.io.IOException: Error scanning context clojars: java.nio.file.FileAlreadyExistsException: /tmp/clojars-tmp10757666929368582455/nexus-maven-repository-index-packer.properties
        at org.apache.maven.index.DefaultNexusIndexer.scan(DefaultNexusIndexer.java:313)
        at org.apache.maven.index.DefaultNexusIndexer.scan(DefaultNexusIndexer.java:258)
        at org.apache.maven.index.cli.NexusIndexerCli.index(NexusIndexerCli.java:448)
        at org.apache.maven.index.cli.NexusIndexerCli.execute(NexusIndexerCli.java:164)
        at org.apache.maven.index.cli.NexusIndexerCli.main(NexusIndexerCli.java:116)
Caused by: java.nio.file.FileAlreadyExistsException: /tmp/clojars-tmp10757666929368582455/nexus-maven-repository-index-packer.properties
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:94)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:213)
        at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:244)
        at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:426)
        at java.base/java.nio.file.Files.newOutputStream(Files.java:215)
        at org.apache.lucene.store.FSDirectory$FSIndexOutput.<init>(FSDirectory.java:394)
        at org.apache.lucene.store.FSDirectory$FSIndexOutput.<init>(FSDirectory.java:387)
        at org.apache.lucene.store.FSDirectory.createOutput(FSDirectory.java:220)
        at org.apache.lucene.store.Directory.copyFrom(Directory.java:181)
        at org.apache.maven.index.context.IndexUtils.copyFile(IndexUtils.java:73)
        at org.apache.maven.index.context.IndexUtils.copyFile(IndexUtils.java:63)
        at org.apache.maven.index.context.IndexUtils.copyDirectory(IndexUtils.java:56)
        at org.apache.maven.index.DefaultNexusIndexer.scan(DefaultNexusIndexer.java:291)
        ... 4 more

Removing ./index/nexus-maven-repository-index-packer.properties allows the subsequent run to succeed.

I encountered this when attempting to upgrade clojars.org from 4.1.2 to 7.1.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions