You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "davisusanibar (via GitHub)" <gi...@apache.org> on 2023/06/29 03:52:02 UTC

[GitHub] [arrow] davisusanibar commented on a diff in pull request #36185: GH-35960: [Java] Detect overflow in allocation

davisusanibar commented on code in PR #36185:
URL: https://github.com/apache/arrow/pull/36185#discussion_r1246065773


##########
java/memory/memory-core/src/main/java/org/apache/arrow/memory/Accountant.java:
##########
@@ -169,9 +169,14 @@ public boolean forceAllocate(long size) {
    */
   private AllocationOutcome.Status allocate(final long size, final boolean incomingUpdatePeak,
       final boolean forceAllocation, AllocationOutcomeDetails details) {
-    final long newLocal = locallyHeldMemory.addAndGet(size);
+    final long oldLocal = locallyHeldMemory.getAndAdd(size);
+    final long newLocal = oldLocal + size;
+    // Borrowed from Math.addExact (but avoid exception here)

Review Comment:
   Is it necessary to postpone exception throws?



-- 
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: github-unsubscribe@arrow.apache.org

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