From 5517df635324ff1157857a875dce46dbf9a47227 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Wed, 11 Jul 2012 21:28:14 +0200 Subject: [PATCH] don't (re) create a string from a numeric timestamp, just return the string we get --- .../java/org/elasticsearch/action/index/IndexRequest.java | 2 +- .../org/elasticsearch/cluster/metadata/MappingMetaData.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/src/main/java/org/elasticsearch/action/index/IndexRequest.java index 5e1a827b77f..b4ef4ded5d2 100644 --- a/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -655,7 +655,7 @@ public class IndexRequest extends ShardReplicationOperationRequest { // generate timestamp if not provided, we always have one post this stage... if (timestamp == null) { - timestamp = String.valueOf(System.currentTimeMillis()); + timestamp = Long.toString(System.currentTimeMillis()); } } diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java b/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java index 11276f63fe1..f8b42697bfd 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java @@ -160,7 +160,9 @@ public class MappingMetaData { public static String parseStringTimestamp(String timestampAsString, FormatDateTimeFormatter dateTimeFormatter) throws TimestampParsingException { long ts; try { + // if we manage to parse it, its a millisecond timestamp, just return the string as is ts = Long.parseLong(timestampAsString); + return timestampAsString; } catch (NumberFormatException e) { try { ts = dateTimeFormatter.parser().parseMillis(timestampAsString); @@ -168,7 +170,7 @@ public class MappingMetaData { throw new TimestampParsingException(timestampAsString); } } - return String.valueOf(ts); + return Long.toString(ts); }