From 8153411c150c2d2edee83fbfae3596a498165879 Mon Sep 17 00:00:00 2001 From: Armin Date: Sun, 6 Aug 2017 10:01:13 +0200 Subject: [PATCH] CLEANUP: Remove unused TimeBiValue Fixes #7920 --- .../src/main/java/org/logstash/Event.java | 3 -- .../org/logstash/bivalues/TimeBiValue.java | 37 ------------------- .../org/logstash/bivalues/BiValueTest.java | 21 ----------- 3 files changed, 61 deletions(-) delete mode 100644 logstash-core/src/main/java/org/logstash/bivalues/TimeBiValue.java diff --git a/logstash-core/src/main/java/org/logstash/Event.java b/logstash-core/src/main/java/org/logstash/Event.java index 6a1614326..31004203e 100644 --- a/logstash-core/src/main/java/org/logstash/Event.java +++ b/logstash-core/src/main/java/org/logstash/Event.java @@ -14,7 +14,6 @@ import org.jruby.RubySymbol; import org.logstash.ackedqueue.Queueable; import org.logstash.bivalues.BiValues; import org.logstash.bivalues.NullBiValue; -import org.logstash.bivalues.TimeBiValue; import org.logstash.bivalues.TimestampBiValue; import org.logstash.ext.JrubyTimestampExtLibrary; @@ -311,8 +310,6 @@ public final class Event implements Cloneable, Queueable { return new Timestamp((String) o); } else if (o instanceof RubyString) { return new Timestamp(o.toString()); - } else if (o instanceof TimeBiValue) { - return new Timestamp(((TimeBiValue) o).javaValue()); } else if (o instanceof JrubyTimestampExtLibrary.RubyTimestamp) { return ((JrubyTimestampExtLibrary.RubyTimestamp) o).getTimestamp(); } else if (o instanceof Timestamp) { diff --git a/logstash-core/src/main/java/org/logstash/bivalues/TimeBiValue.java b/logstash-core/src/main/java/org/logstash/bivalues/TimeBiValue.java deleted file mode 100644 index cbbee73c8..000000000 --- a/logstash-core/src/main/java/org/logstash/bivalues/TimeBiValue.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.logstash.bivalues; - -import org.joda.time.DateTime; -import org.jruby.Ruby; -import org.jruby.RubyTime; - -import java.io.ObjectStreamException; - - -public class TimeBiValue extends BiValue { - - public TimeBiValue(RubyTime rubyValue) { - this.rubyValue = rubyValue; - javaValue = null; - } - - public TimeBiValue(DateTime javaValue) { - this.javaValue = javaValue; - rubyValue = null; - } - - private TimeBiValue() { - } - - protected void addRuby(Ruby runtime) { - rubyValue = RubyTime.newTime(runtime, javaValue); - } - - protected void addJava() { - javaValue = rubyValue.getDateTime(); - } - - // Called when object is to be serialized on a stream to allow the object to substitute a proxy for itself. - private Object writeReplace() throws ObjectStreamException { - return newProxy(this); - } -} diff --git a/logstash-core/src/test/java/org/logstash/bivalues/BiValueTest.java b/logstash-core/src/test/java/org/logstash/bivalues/BiValueTest.java index 9f87ce08b..a8cf82502 100644 --- a/logstash-core/src/test/java/org/logstash/bivalues/BiValueTest.java +++ b/logstash-core/src/test/java/org/logstash/bivalues/BiValueTest.java @@ -6,14 +6,12 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.math.BigDecimal; import java.math.BigInteger; -import org.joda.time.DateTime; import org.jruby.RubyBignum; import org.jruby.RubyBoolean; import org.jruby.RubyFixnum; import org.jruby.RubyFloat; import org.jruby.RubyInteger; import org.jruby.RubySymbol; -import org.jruby.RubyTime; import org.jruby.ext.bigdecimal.RubyBigDecimal; import org.junit.Test; import org.logstash.TestBase; @@ -131,25 +129,6 @@ public class BiValueTest extends TestBase { assertEquals(ruby.getNil(), subject.rubyValue(ruby)); } - @Test - public void testTimeBiValueFromRuby() { - DateTime t = DateTime.now(); - RubyTime now = RubyTime.newTime(ruby, t); - TimeBiValue subject = new TimeBiValue(now); - assertTrue(subject.hasRubyValue()); - assertFalse(subject.hasJavaValue()); - assertEquals(t, subject.javaValue()); - } - - @Test - public void testTimeBiValueFromJava() { - DateTime t = DateTime.now(); - TimeBiValue subject = new TimeBiValue(t); - assertFalse(subject.hasRubyValue()); - assertTrue(subject.hasJavaValue()); - assertEquals(RubyTime.newTime(ruby, t), subject.rubyValue(ruby)); - } - @Test public void testBigIntegerBiValueFromRuby() { BigInteger s = BigInteger.valueOf(12345678L);