-
Notifications
You must be signed in to change notification settings - Fork 36
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
Conversation
Generate changelog in
|
private FileStatus toReturnFileStatus(FileStatus status) { | ||
status.setPath(from(status.getPath())); | ||
return status; | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
Lines 121 to 135 in d0853ab
@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)); | |
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Released 3.4.0 |
* 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]>
…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]>
Before this PR
The current implementation of
PathConvertingFileSystem#toReturnFileStatus
, the method that converts file statuses from the delegating file system, creates newFileStatus
objects. This doesn't work with custom implementation ofFileStatus
.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==