Skip to content

Commit

Permalink
[CELEBORN-1079] Fix use of GuardedBy in client-flink/common
Browse files Browse the repository at this point in the history
* Fix use of `GuardedBy` on nonexistant lock.
* Annotate methods, which are expected to be called with lock held, with `GuardedBy` so that error prone can analyze all invocations

There is no functional change, but it helps errorprone analysis.

No

Unit tests

Closes #2029 from mridulm/fix-flink-guarded-by-annotation.

Authored-by: Mridul Muralidharan <mridulatgmail.com>
Signed-off-by: zky.zhoukeyong <[email protected]>
  • Loading branch information
mridulm authored and waitinfuture committed Oct 24, 2023
1 parent 49ea881 commit 6dc30d3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Arrays;

import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
import javax.annotation.concurrent.NotThreadSafe;

import org.apache.flink.core.memory.MemorySegment;
Expand Down Expand Up @@ -63,7 +62,6 @@ public class PartitionSortedBuffer implements SortBuffer {
private final BufferPool bufferPool;

/** A segment list as a joint buffer which stores all records and index entries. */
@GuardedBy("lock")
private final ArrayList<MemorySegment> buffers = new ArrayList<>();

/** Addresses of the first record's index entry for each subpartition. */
Expand Down Expand Up @@ -92,7 +90,6 @@ public class PartitionSortedBuffer implements SortBuffer {
// For writing
// ---------------------------------------------------------------------------------------------
/** Whether this sort buffer is released. A released sort buffer can not be used. */
@GuardedBy("lock")
private boolean isReleased;
/** Array index in the segment list of the current available buffer for writing. */
private int writeSegmentIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public void recycle(ByteBuffer buffer) {
}
}

@GuardedBy("lock")
private int assignCredits(CreditListener creditListener) {
assert Thread.holdsLock(lock);

Expand All @@ -176,6 +177,7 @@ private int assignCredits(CreditListener creditListener) {
return numCredits;
}

@GuardedBy("lock")
private List<CreditAssignment> dispatchReservedCredits() {
assert Thread.holdsLock(lock);

Expand Down

0 comments on commit 6dc30d3

Please sign in to comment.