Skip to content

Fix ScipWriter temp file creation on file systems without POSIX permissions - #1049

Open
cfloersch wants to merge 1 commit into
scip-code:mainfrom
cfloersch:main
Open

cfloersch wants to merge 1 commit into
scip-code:mainfrom
cfloersch:main

Conversation

@cfloersch

Copy link
Copy Markdown

Problem

ScipWriter creates its temporary output file with the PosixFilePermissions attribute rw-r--r--:

Files.createTempFile("scip-aggregator", "index.scip",
    PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--")));

On file systems that do not support POSIX permissions, such as NTFS on Windows, this throws:

java.lang.UnsupportedOperationException: 'posix:permissions' not supported as initial attribute

scip-java aggregate therefore exits before it writes index.scip. This affects anything that runs the aggregator on Windows, including running ScipJava aggregate from a Maven build.

ScipWriter is the only class in scip-aggregator, scip-java, scip-javac and scip-shared that uses POSIX file permissions.

Fix

Create the temp file with the rw-r--r-- attribute only when the default file system reports the posix attribute view. Otherwise create it with the default permissions. Behavior on POSIX file systems is unchanged.

Testing

Added ScipWriterTest, which creates a ScipWriter, builds an empty index into a temp directory, and asserts the output file exists. It does not simulate a non-POSIX file system, so it exercises the fix only on Windows runners.

  • Without the fix, on Windows 11 with JDK 21: the test fails with the exception above.
  • With the fix: gradle :scip-aggregator:test and gradle spotlessCheck pass.
  • Validated Posix system - Fedora 44

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant