From 0325cc923b47550918b79f140a81802abda1ff9a Mon Sep 17 00:00:00 2001 From: Will Jones Date: Thu, 14 Jul 2022 18:21:55 -0700 Subject: [PATCH] fix: add trailing slash enforcement to HDFS --- cpp/src/arrow/filesystem/hdfs.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpp/src/arrow/filesystem/hdfs.cc b/cpp/src/arrow/filesystem/hdfs.cc index 6f16667ffdc..8709ab45625 100644 --- a/cpp/src/arrow/filesystem/hdfs.cc +++ b/cpp/src/arrow/filesystem/hdfs.cc @@ -246,12 +246,14 @@ class HadoopFileSystem::Impl { } Result> OpenInputStream(const std::string& path) { + ARROW_RETURN_NOT_OK(internal::AssertNoTrailingSlash(path)); std::shared_ptr file; RETURN_NOT_OK(client_->OpenReadable(path, io_context_, &file)); return file; } Result> OpenInputFile(const std::string& path) { + ARROW_RETURN_NOT_OK(internal::AssertNoTrailingSlash(path)); std::shared_ptr file; RETURN_NOT_OK(client_->OpenReadable(path, io_context_, &file)); return file; @@ -285,6 +287,7 @@ class HadoopFileSystem::Impl { Result> OpenOutputStreamGeneric( const std::string& path, bool append) { + ARROW_RETURN_NOT_OK(internal::AssertNoTrailingSlash(path)); std::shared_ptr stream; RETURN_NOT_OK(client_->OpenWritable(path, append, options_.buffer_size, options_.replication, options_.default_block_size,