Skip to content

Commit 94a2015

Browse files
author
Pindikura Ravindra
committed
ARROW-4104: [Java] fix a race condition in AllocationManager
1 parent 1291274 commit 94a2015

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

java/memory/src/main/java/org/apache/arrow/memory/AllocationManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public boolean transferBalance(final BufferLedger target) {
230230
// since two balance transfers out from the allocator manager could cause incorrect
231231
// accounting, we need to ensure
232232
// that this won't happen by synchronizing on the allocator manager instance.
233-
synchronized (this) {
233+
synchronized (AllocationManager.this) {
234234
if (owningLedger != this) {
235235
return true;
236236
}
@@ -310,7 +310,7 @@ public int decrement(int decrement) {
310310
allocator.assertOpen();
311311

312312
final int outcome;
313-
synchronized (this) {
313+
synchronized (AllocationManager.this) {
314314
outcome = bufRefCnt.addAndGet(-decrement);
315315
if (outcome == 0) {
316316
lDestructionTime = System.nanoTime();
@@ -411,7 +411,7 @@ public int getSize() {
411411
* @return Amount of accounted(owned) memory associated with this ledger.
412412
*/
413413
public int getAccountedSize() {
414-
synchronized (this) {
414+
synchronized (AllocationManager.this) {
415415
if (owningLedger == this) {
416416
return size;
417417
} else {

0 commit comments

Comments
 (0)