Skip to content

Commit

Permalink
Fix access logger not erroring on failure to open file
Browse files Browse the repository at this point in the history
Signed-off-by: Raven Black <ravenblack@dropbox.com>
  • Loading branch information
ravenblackx committed Feb 21, 2025
1 parent ba7bf5f commit 0b89b8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion source/common/access_log/access_log_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ AccessLogManagerImpl::createAccessLog(const Filesystem::FilePathAndType& file_in
}

Api::IoCallBoolResult open_result = file->open(default_flags);
if (!open_result.return_value_) {
if (!open_result.ok()) {
return absl::InvalidArgumentError(fmt::format("unable to open file '{}': {}", file_name,
open_result.err_->getErrorDetails()));
}
Expand Down
3 changes: 2 additions & 1 deletion test/common/access_log/access_log_manager_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class AccessLogManagerImplTest : public testing::Test {
};

TEST_F(AccessLogManagerImplTest, BadFile) {
EXPECT_CALL(*file_, open_(_)).WillOnce(Return(ByMove(Filesystem::resultFailure<bool>(false, 0))));
EXPECT_CALL(*file_, open_(_))
.WillOnce(Return(ByMove(Filesystem::resultFailure<bool>(false, -1))));
EXPECT_FALSE(
access_log_manager_
.createAccessLog(Filesystem::FilePathAndType{Filesystem::DestinationType::File, "foo"})
Expand Down

0 comments on commit 0b89b8b

Please sign in to comment.