diff --git a/java-lib/src/main/java/com/wavefront/ingester/IngesterFormatter.java b/java-lib/src/main/java/com/wavefront/ingester/IngesterFormatter.java index a5ff5d9ac..dbe2ff3ef 100644 --- a/java-lib/src/main/java/com/wavefront/ingester/IngesterFormatter.java +++ b/java-lib/src/main/java/com/wavefront/ingester/IngesterFormatter.java @@ -82,10 +82,6 @@ public boolean apply(Token input) { throw new RuntimeException("Could not parse: " + input); } - // fix up the point. - if (point.getTimestamp() == null) { - point.setTimestamp(System.currentTimeMillis()); - } String host = null; Map annotations = point.getAnnotations(); if (annotations != null) { @@ -268,8 +264,12 @@ public AdaptiveTimestamp(boolean optional) { public void consume(Queue tokenQueue, ReportPoint point) { Token peek = tokenQueue.peek(); if (peek == null) { - if (optional) return; - else throw new RuntimeException("Expecting timestamp, found EOF"); + if (optional) { + point.setTimestamp(System.currentTimeMillis()); + return; + } else { + throw new RuntimeException("Expecting timestamp, found EOF"); + } } if (peek.getType() == DSWrapperLexer.Number) { try { @@ -288,6 +288,8 @@ public void consume(Queue tokenQueue, ReportPoint point) { } } else if (!optional) { throw new RuntimeException("Expecting timestamp, found: " + peek.getText()); + } else { + point.setTimestamp(System.currentTimeMillis()); } } }