From ad5ffdf483d5071378528a619b55ee504676b8b9 Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Tue, 15 Sep 2015 13:31:14 -0700 Subject: [PATCH] Nix Committers.supplierOf; Suppliers.ofInstance is good enough. --- .../segment/realtime/plumber/Committers.java | 42 +++++++------------ .../plumber/RealtimePlumberSchoolTest.java | 2 +- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/server/src/main/java/io/druid/segment/realtime/plumber/Committers.java b/server/src/main/java/io/druid/segment/realtime/plumber/Committers.java index b3089c592fa..7659511369c 100644 --- a/server/src/main/java/io/druid/segment/realtime/plumber/Committers.java +++ b/server/src/main/java/io/druid/segment/realtime/plumber/Committers.java @@ -20,6 +20,7 @@ package io.druid.segment.realtime.plumber; import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; import io.druid.data.input.Committer; import io.druid.data.input.Firehose; import io.druid.data.input.FirehoseV2; @@ -43,22 +44,21 @@ public class Committers public static Supplier supplierFromRunnable(final Runnable runnable) { - return supplierOf( - new Committer() - { - @Override - public Object getMetadata() - { - return null; - } + final Committer committer = new Committer() + { + @Override + public Object getMetadata() + { + return null; + } - @Override - public void run() - { - runnable.run(); - } - } - ); + @Override + public void run() + { + runnable.run(); + } + }; + return Suppliers.ofInstance(committer); } public static Supplier supplierFromFirehose(final Firehose firehose) @@ -103,16 +103,4 @@ public class Committers { return NIL; } - - public static Supplier supplierOf(final Committer committer) - { - return new Supplier() - { - @Override - public Committer get() - { - return committer; - } - }; - } } diff --git a/server/src/test/java/io/druid/segment/realtime/plumber/RealtimePlumberSchoolTest.java b/server/src/test/java/io/druid/segment/realtime/plumber/RealtimePlumberSchoolTest.java index 2d3b0682dc8..fcc704fff8a 100644 --- a/server/src/test/java/io/druid/segment/realtime/plumber/RealtimePlumberSchoolTest.java +++ b/server/src/test/java/io/druid/segment/realtime/plumber/RealtimePlumberSchoolTest.java @@ -311,7 +311,7 @@ public class RealtimePlumberSchoolTest EasyMock.expect(row.getTimestampFromEpoch()).andReturn(0L); EasyMock.expect(row.getDimensions()).andReturn(new ArrayList()); EasyMock.replay(row); - plumber.add(row, Committers.supplierOf(Committers.nil())); + plumber.add(row, Suppliers.ofInstance(Committers.nil())); final CountDownLatch doneSignal = new CountDownLatch(1);