Skip to content

Commit

Permalink
handle empty timestamp tag without processing (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
havetisyan authored May 23, 2018
1 parent 93e818d commit 37ad892
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 8 additions & 3 deletions servers/zms/src/main/java/com/yahoo/athenz/zms/ZMSImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 37ad892

Please sign in to comment.