uschindler commented on issue #16861:
URL: https://github.com/apache/lucene/issues/16861#issuecomment-6265772826

   I'd change this to use an `final AtomicLong sizeInBytes = new AtomicLong(-1)`
   
   In the getter use `updateAndGet()`, e.g., something like:
   
   ```java
   return sizeInBytes.updateAndGet(size -> {
     if (size == -1) {
       size = 0;
       for (final String fileName : files()) {
         sum += info.dir.fileLength(fileName);
         size += info.dir.fileLength(fileName);
       }
     }
     return size;
   });
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to