Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't allow activities if the subscriber is current, or the connection to Kinesis is broken #374

Merged
merged 3 commits into from
Aug 20, 2018
Merged
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 @@ -305,18 +305,44 @@ public void subscribe(Subscriber<? super ProcessRecordsInput> s) {
subscriber.onSubscribe(new Subscription() {
@Override
public void request(long n) {
long previous = outstandingRequests;
outstandingRequests += n;
if (previous <= 0) {
flow.request(1);
synchronized (lockObject) {
if (subscriber != s) {
log.warn(
"{}: (FanOutRecordsPublisher/Subscription#request) - Rejected an attempt to request({}), because subscribers don't match.",
shardId, n);
return;
}
if (flow == null) {
//
// Flow has been terminated, so we can't make any requests on it anymore.
//
log.debug(
"{}: (FanOutRecordsPublisher/Subscription#request) - Request called for a null flow.",
shardId);
errorOccurred(flow, new IllegalStateException("Attempted to request on a null flow."));
return;
}
long previous = outstandingRequests;
outstandingRequests += n;
if (previous <= 0) {
flow.request(1);
}
}
}

@Override
public void cancel() {
synchronized (lockObject) {
if (subscriber != s) {
log.warn(
"{}: (FanOutRecordsPublisher/Subscription#cancel) - Rejected attempt to cancel subscription, because subscribers don't match.",
shardId);
return;
}
if (!hasValidSubscriber()) {
log.warn("{}: Cancelled called even with an invalid subscriber", shardId);
log.warn(
"{}: (FanOutRecordsPublisher/Subscription#cancel) - Cancelled called even with an invalid subscriber",
shardId);
}
subscriber = null;
if (flow != null) {
Expand Down