Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Let getFileAttributeView() return null for unsupported view class. #485

Merged

Conversation

chbriem
Copy link
Contributor

@chbriem chbriem commented Jun 25, 2024

Issue #, if available:
No issue created this time. If needed, I can create one later.

Description of changes:
Observed when trying to use JDK's Files.move() method. This method uses the java.nio.file.CopyMoveHelper#copyToForeignTarget method. The implementation tries to get the PosixFileAttributeView (in line 109). This fails for the S3 implementation with an UnsupportedOperationException, which is not caught by JDK's code, resulting in the move operation to fail.

Having read the method description, I'm of the opinion that the method should return null in case of an unsupported view type. This would at least be compliant with the method comment in the copyToForeignTarget method (line 108):

// retrieve source posix view, null if unsupported

I've adapted the test accordingly.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Contributor

@markjschreiber markjschreiber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

@markjschreiber markjschreiber merged commit 80940af into awslabs:main Jun 25, 2024
1 check passed
@chbriem chbriem deleted the fix/get-file-attribute-returns-null branch June 25, 2024 18:20
stefanofornari pushed a commit to stefanofornari/aws-java-nio-spi-for-s3 that referenced this pull request Aug 6, 2024
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.

2 participants