dsmiley commented on code in PR #2021: URL: https://github.com/apache/solr/pull/2021#discussion_r1366914071
########## solr/core/src/java/org/apache/solr/update/VersionBucket.java: ########## @@ -31,14 +31,41 @@ * ignores the <code>lockTimeoutMs</code>. */ public class VersionBucket { - public long highest; + private long highest; + + /** + * @param highest the initial value of this bucket highest version. + */ + public VersionBucket(long highest) { + setHighestIfGreater(highest); + } + + /** + * Updates the highest version if the current bucket value is not zero and if the provided value + * is greater than the current bucket value. The caller must synchronize on this bucket when + * calling this method. + */ public void updateHighest(long val) { if (highest != 0) { - highest = Math.max(highest, Math.abs(val)); + setHighestIfGreater(Math.abs(val)); + } + } + + /** + * Sets the highest version if the provided value is greater than the current bucket value. The + * caller must synchronize on this bucket when calling this method. + */ + public void setHighestIfGreater(long val) { + if (val > highest) { + this.highest = val; } } + public long getHighest() { Review Comment: The methods we're talking about are really trivial. And the concurrency concern is low probability. I wouldn't worry about a negative perf impact that you hurt anything here. -- 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: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org