showuon commented on a change in pull request #11234: URL: https://github.com/apache/kafka/pull/11234#discussion_r721155436
########## File path: streams/src/main/java/org/apache/kafka/streams/state/internals/CachingSessionStore.java ########## @@ -212,18 +216,15 @@ public void remove(final Windowed<Bytes> sessionKey) { final Bytes keyTo, final long earliestSessionEndTime, final long latestSessionStartTime) { - if (keyFrom.compareTo(keyTo) > 0) { - LOG.warn("Returning empty iterator for fetch with invalid key range: from > to. " + - "This may be due to range arguments set in the wrong order, " + - "or serdes that don't preserve ordering when lexicographically comparing the serialized bytes. " + - "Note that the built-in numerical serdes do not follow this for negative numbers"); + if (keyFrom != null && keyTo != null && keyFrom.compareTo(keyTo) > 0) { + LOG.warn(INVALID_RANGE_WARN_MSG); return KeyValueIterators.emptyIterator(); } validateStoreOpen(); - final Bytes cacheKeyFrom = cacheFunction.cacheKey(keySchema.lowerRange(keyFrom, earliestSessionEndTime)); - final Bytes cacheKeyTo = cacheFunction.cacheKey(keySchema.upperRange(keyTo, latestSessionStartTime)); + final Bytes cacheKeyFrom = keyFrom == null ? null : cacheFunction.cacheKey(keySchema.lowerRange(keyFrom, earliestSessionEndTime)); Review comment: Good question! It can, but I think it might be better to keep it as is, because it needs to change more API to allow null keys, ex: in this case, we need to let `lowerRange` allow null `keyFrom`, and return `null`, then, `cacheKey` should accept `null` key, and return `null`. Thank you. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org