diff --git a/servers/zms/src/main/java/com/yahoo/athenz/zms/ZMSImpl.java b/servers/zms/src/main/java/com/yahoo/athenz/zms/ZMSImpl.java index ece08bfa9e7..9b0906b453a 100644 --- a/servers/zms/src/main/java/com/yahoo/athenz/zms/ZMSImpl.java +++ b/servers/zms/src/main/java/com/yahoo/athenz/zms/ZMSImpl.java @@ -3998,9 +3998,13 @@ long getModTimestamp(String matchingTag) { matchingTag = removeQuotes(matchingTag); if (LOG.isDebugEnabled()) { - LOG.debug("getModTimestamp: matching tag (" + matchingTag + ")"); + LOG.debug("getModTimestamp: matching tag ({})", matchingTag); } - + + if (matchingTag.isEmpty()) { + return timestamp; + } + try { Timestamp tagStamp = Timestamp.fromString(matchingTag); if (tagStamp == null) { @@ -4009,7 +4013,8 @@ long getModTimestamp(String matchingTag) { timestamp = tagStamp.millis(); } catch (IllegalArgumentException exc) { if (LOG.isWarnEnabled()) { - LOG.warn("getModTimestamp: matching tag(" + matchingTag + ") has bad format. Return -1L by default."); + LOG.warn("getModTimestamp: matching tag({}) has bad format. Return 0 by default.", + matchingTag); } } diff --git a/servers/zms/src/test/java/com/yahoo/athenz/zms/ZMSImplTest.java b/servers/zms/src/test/java/com/yahoo/athenz/zms/ZMSImplTest.java index 6721124eb5c..924d12213a7 100644 --- a/servers/zms/src/test/java/com/yahoo/athenz/zms/ZMSImplTest.java +++ b/servers/zms/src/test/java/com/yahoo/athenz/zms/ZMSImplTest.java @@ -14373,5 +14373,13 @@ public void testValidateString() { assertEquals(ex.getCode(), 400); } } + + @Test + public void testgetModTimestampEmtpy() { + ZMSImpl zmsImpl = zmsInit(); + assertEquals(zmsImpl.getModTimestamp(null), 0); + assertEquals(zmsImpl.getModTimestamp("\"\""), 0); + assertEquals(zmsImpl.getModTimestamp(""), 0); + } }