Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.InterruptedIOException;
import java.io.UncheckedIOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.AccessDeniedException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -1652,7 +1653,12 @@ public Path makeQualified(final Path path) {
LOG.debug("Stripping trailing '/' from {}", q);
Copy link
Contributor

Choose a reason for hiding this comment

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

how about pulling out everything in this method after the super.makeQualified(path); call into a static method in S3AUtils? that way it could be tested in a unit test rather than waiting until someone runs the integration tests. faster and with yetus coverage

// deal with an empty "/" at the end by mapping to the parent and
// creating a new path from it
q = new Path(urlString.substring(0, urlString.length() - 1));
try {
q = new Path(new URI(urlString.substring(0, urlString.length() - 1)));
} catch (URISyntaxException e) {
LOG.error(String.format("Error removing trailing / from path %s", path.toString()));
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. We'd want a LogExactlyOnce so if there is a problem it only ever gets logged once, not every time a path was loaded.
  2. it should be at warn, not error
  3. +use slf4j {} expansions.
    thanks

return q;
}
}
}
if (!q.isRoot() && q.getName().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@ public void testPathFixup() throws Throwable {
fs.makeQualified(pathFromTrailingURI));
}

@Test
public void testQualifyPathWithWhitespace() {
final S3AFileSystem fs = getFileSystem();
Path pathWithSpace = fs.makeQualified(new Path("path with space"));
Path pathWithSpaceTrailingSlash = fs.makeQualified(new Path("path with space/"));
// removing trailing / should not recreate the Path object in a URL encoded way
assertEquals(pathWithSpace, pathWithSpaceTrailingSlash);
}

/**
* Verify that paths with a trailing "//" are fixed up.
*/
Expand Down