You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/11/15 13:56:28 UTC

[GitHub] [lucene] benwtrent commented on a diff in pull request #11923: enable error-prone "narrow calculation" check

benwtrent commented on code in PR #11923:
URL: https://github.com/apache/lucene/pull/11923#discussion_r1022817060


##########
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java:
##########
@@ -85,7 +85,7 @@ final class DocumentsWriterFlushControl implements Accountable, Closeable {
     this.perThreadPool = documentsWriter.perThreadPool;
     this.flushPolicy = config.getFlushPolicy();
     this.config = config;
-    this.hardMaxBytesPerDWPT = config.getRAMPerThreadHardLimitMB() * 1024 * 1024;
+    this.hardMaxBytesPerDWPT = config.getRAMPerThreadHardLimitMB() * 1024L * 1024L;

Review Comment:
   i *think* the thing to do here would have been
   
   `Math.multiplyExact(config.getRAMPerThreadHardLimitMB(), 1024 * 1024);` It seems it's invalid if this is every more than can be contained in an integer?:
   
   https://github.com/apache/lucene/blob/b5795db0cf517f8942eed868752249df9b105603/lucene/core/src/java/org/apache/lucene/index/IndexWriterConfig.java#L343-L359



-- 
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-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org