Skip to content

Commit

Permalink
fix the JSONFormatter flush & close_section
Browse files Browse the repository at this point in the history
  • Loading branch information
Aran85 committed Aug 1, 2015
1 parent 5c6075f commit 90dde3b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/common/Formatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ void JSONFormatter::flush(std::ostream& os)
{
finish_pending_string();
os << m_ss.str();
if (m_pretty)
os << "\n";
m_ss.clear();
m_ss.str("");
}
Expand Down Expand Up @@ -238,6 +236,8 @@ void JSONFormatter::close_section()
}
m_ss << (entry.is_array ? ']' : '}');
m_stack.pop_back();
if (m_pretty && (m_stack.size() == 0))
m_ss << "\n";
}

void JSONFormatter::finish_pending_string()
Expand Down
1 change: 1 addition & 0 deletions src/test/crush/CrushWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ TEST(CrushWrapper, dump_rules) {
Formatter *f = Formatter::create("json-pretty");
c->dump_rules(f);
stringstream ss;
f->close_section();
f->flush(ss);
delete f;
EXPECT_EQ("\n", ss.str());
Expand Down

0 comments on commit 90dde3b

Please sign in to comment.