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

PathConvertingFileSystem converts FileStatus objects in-place #638

Merged
merged 3 commits into from
Dec 4, 2022

Conversation

rshkv
Copy link
Contributor

@rshkv rshkv commented Dec 3, 2022

Before this PR

The current implementation of PathConvertingFileSystem#toReturnFileStatus, the method that converts file statuses from the delegating file system, creates new FileStatus objects. This doesn't work with custom implementation of FileStatus.

After this PR

Convert file statuses from the delegating file status by setting the new path instead over creating a whole new object. I couldn't find an implementation of FileStatus that would be negatively affected by this. To the contrary: if file system implementations return custom file status implementation, the delegating file system should respect those and not return new statuses of a different type.

==COMMIT_MSG==
PathConvertingFileSystem renames paths without creating new FileStatus objects.
==COMMIT_MSG==

@changelog-app
Copy link

changelog-app bot commented Dec 3, 2022

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

PathConvertingFileSystem renames paths without creating new FileStatus objects.

Check the box to generate changelog(s)

  • Generate changelog entry

Comment on lines +157 to 160
private FileStatus toReturnFileStatus(FileStatus status) {
status.setPath(from(status.getPath()));
return status;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a test case that covers the behavior we want here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, PathConvertingFileSystemTest covers the conversion here:

@Test
public void listStatus() throws Exception {
when(delegate.listStatus(DELEGATE_PATH)).thenReturn(new FileStatus[] {fileStatus(DELEGATE_PATH)});
FileStatus[] fileStatuses = convertingFs.listStatus(PATH);
assertThat(fileStatuses).containsExactly(fileStatus(RETURN_PATH));
}
@Test
public void getFileStatus() throws Exception {
when(delegate.getFileStatus(DELEGATE_PATH)).thenReturn(fileStatus(DELEGATE_PATH));
FileStatus fileStatus = convertingFs.getFileStatus(PATH);
assertThat(fileStatus).isEqualTo(fileStatus(RETURN_PATH));
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also testing e.g. the object reference felt too much like an implementation detail. But can add.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On further thought testing the new behavior makes sense: added in 410ff78.

@rshkv rshkv changed the title PathConvertingFileSystem renames paths without creating new FileStatus objects PathConvertingFileSystem converts FileStatus objects in-place Dec 3, 2022
@rshkv rshkv merged commit b5112a2 into develop Dec 4, 2022
@svc-autorelease
Copy link
Collaborator

Released 3.4.0

leonz pushed a commit that referenced this pull request Dec 6, 2022
* PathConvertingFileSystem renames paths without creating new FileStatus objects

* Add generated changelog entries

* Reflect updated FileStatus conversion in test

Co-authored-by: svc-changelog <[email protected]>
schlosna pushed a commit that referenced this pull request Dec 6, 2022
…n-place (#639)

* PathConvertingFileSystem converts FileStatus objects in-place (#638)

* PathConvertingFileSystem renames paths without creating new FileStatus objects

* Add generated changelog entries

* Reflect updated FileStatus conversion in test

Co-authored-by: svc-changelog <[email protected]>

* fix test

Co-authored-by: Willi Raschkowski <[email protected]>
Co-authored-by: svc-changelog <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants