Skip to content

Commit

Permalink
optimized code that gets default formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhks committed Dec 17, 2019
1 parent 1b40fb4 commit 670aa9e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void formatAndSink(ReportedMetric metric)
{
for (SinkQueue sinkQueue : m_sinkQueueList)
{
Formatter formatter = m_formatters.getOrDefault(sinkQueue.getSinkName(), sinkQueue.getSink().getDefaultFormatter());
Formatter formatter = m_formatters.computeIfAbsent(sinkQueue.getSinkName(), (sq) -> sinkQueue.getSink().getDefaultFormatter());

FormattedMetric formattedMetric = new FormattedMetric(metric, m_props, m_tags, m_help);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public void testDoubleCollectors()
ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);

verify(m_sink1).reportMetrics(captor.capture());
verify(m_sink1).getDefaultFormatter();
verifyNoMoreInteractions(m_sink1);

assertThat(captor.getValue().get(0)).isEqualTo(formattedMetric);
Expand Down

0 comments on commit 670aa9e

Please sign in to comment.