Skip to content

Commit

Permalink
Add more information to unexpected assertion failure
Browse files Browse the repository at this point in the history
Issue: #4532

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=208968252
  • Loading branch information
ojw28 committed Aug 17, 2018
1 parent 95bc607 commit 4662e58
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,18 @@ public synchronized void release(Allocation[] allocations) {
}
for (Allocation allocation : allocations) {
// Weak sanity check that the allocation probably originated from this pool.
Assertions.checkArgument(allocation.data == initialAllocationBlock
|| allocation.data.length == individualAllocationSize);
if (allocation.data != initialAllocationBlock
&& allocation.data.length != individualAllocationSize) {
throw new IllegalArgumentException(
"Unexpected allocation: "
+ System.identityHashCode(allocation.data)
+ ", "
+ System.identityHashCode(initialAllocationBlock)
+ ", "
+ allocation.data.length
+ ", "
+ individualAllocationSize);
}
availableAllocations[availableCount++] = allocation;
}
allocatedCount -= allocations.length;
Expand Down

0 comments on commit 4662e58

Please sign in to comment.