Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
public class FlowController {
/** Base exception that signals a flow control state. */
public abstract static class FlowControlException extends Exception {
private FlowControlException() {}
private FlowControlException(String message) {
super(message);
}
}

/**
Expand All @@ -68,18 +70,13 @@ public static final class MaxOutstandingElementCountReachedException
private final long currentMaxElementCount;

public MaxOutstandingElementCountReachedException(long currentMaxElementCount) {
super("The maximum number of batch elements: " + currentMaxElementCount + " has been reached.");
this.currentMaxElementCount = currentMaxElementCount;
}

public long getCurrentMaxBatchElementCount() {
return currentMaxElementCount;
}

@Override
public String toString() {
return String.format(
"The maximum number of batch elements: %d have been reached.", currentMaxElementCount);
}
}

/**
Expand All @@ -91,18 +88,13 @@ public static final class MaxOutstandingRequestBytesReachedException
private final long currentMaxBytes;

public MaxOutstandingRequestBytesReachedException(long currentMaxBytes) {
super("The maximum number of batch bytes: " + currentMaxBytes + " has been reached.");
this.currentMaxBytes = currentMaxBytes;
}

public long getCurrentMaxBatchBytes() {
return currentMaxBytes;
}

@Override
public String toString() {
return String.format(
"The maximum number of batch bytes: %d have been reached.", currentMaxBytes);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,4 +774,18 @@ private List<Future<?>> testConcurrentUpdates(
executors.shutdown();
return reserveReleaseFuture;
}

@Test
public void testExceptionGetMessage() {
FlowController.MaxOutstandingElementCountReachedException elementException =
new FlowController.MaxOutstandingElementCountReachedException(100);
assertThat(elementException.getMessage())
.isEqualTo("The maximum number of batch elements: 100 has been reached.");

FlowController.MaxOutstandingRequestBytesReachedException bytesException =
new FlowController.MaxOutstandingRequestBytesReachedException(500);
assertThat(bytesException.getMessage())
.isEqualTo("The maximum number of batch bytes: 500 has been reached.");
}
}

Loading