Skip to content

Commit

Permalink
Merge pull request #153 from Netflix/dev/sy/enhancelogging
Browse files Browse the repository at this point in the history
Enhance log for key size check
  • Loading branch information
shy-1234 authored Jan 13, 2025
2 parents 9ddd6a9 + 6d7777e commit 6c3773d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public void testKeySizeCheck() throws Exception {
} catch(Exception e) {
exceptionThrown = true;
if (log.isDebugEnabled()) log.debug("Check key length: " + longKey + ": INVALID");
assertTrue(e.getMessage().contains(longKey), "Error message should include the invalid key.");
assertTrue(e.getMessage().contains(Integer.toString(longKey.length())), "Error message should include the key length of the invalid key.");
}
assertTrue(exceptionThrown);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ EVCacheKey getEVCacheKey(final String key) {
}

if (canonicalKey.length() > this.maxKeyLength.get() && !hashKey.get() && !autoHashKeys.get()) {
throw new IllegalArgumentException("Key is too long (maxlen = " + this.maxKeyLength.get() + ')');
final String errMsg = String.format("CanonicalKey ``%s`` is too long (maxLen = %d, keyLen = %d, canonicalKeyLen = %d)", canonicalKey, this.maxKeyLength.get(), key.length(), canonicalKey.length());
log.warn(errMsg);
throw new IllegalArgumentException(errMsg);
}

boolean shouldHashKeyAtAppLevel = hashKey.get() || (canonicalKey.length() > this.maxKeyLength.get() && autoHashKeys.get());
Expand Down

0 comments on commit 6c3773d

Please sign in to comment.