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

Fixing issue with ResourceNotFound around SubscribeToShard #359

Merged
merged 5 commits into from
Aug 13, 2018

Conversation

sahilpalvia
Copy link
Contributor

Issue #, if available:

  • ResourceNotFound for SubscribeToShard causing the FanOutRecordPublisher to spin instead of marking it as SHARD_END and deleting the lease

Description of changes:

  • Calling onNext and onComplete if throwable is of the kind ResourceNotFound.
  • Adding testing for ResourceNotFound
  • Updating version to 2.0.1-SNAPSHOT

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

* Calling onNext and onComplete if throwable is of the kind ResourceNotFound.
* Adding testing for ResourceNotFound
* Updating version to 2.0.1-SNAPSHOT
@sahilpalvia sahilpalvia requested a review from pfifer August 9, 2018 17:29
* Throwing exception from RecordFlow.exceptionOccured
.forClass(FanOutRecordsPublisher.RecordFlow.class);
ArgumentCaptor<ProcessRecordsInput> inputCaptor = ArgumentCaptor.forClass(ProcessRecordsInput.class);

Subscriber<ProcessRecordsInput> subscriber = spy(new Subscriber<ProcessRecordsInput>() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spies are generally not recommended, you should be able to use a mock here.

@@ -124,9 +126,19 @@ private void errorOccurred(RecordFlow triggeringFlow, Throwable t) {
outstandingRequests = 0;

try {
subscriber.onError(t);
if (t.getCause() instanceof ResourceNotFoundException) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this into a method?

@@ -124,9 +126,19 @@ private void errorOccurred(RecordFlow triggeringFlow, Throwable t) {
outstandingRequests = 0;

try {
subscriber.onError(t);
if (t.getCause() instanceof ResourceNotFoundException) {
log.warn(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be a warning, as it's handled.

Sahil Palvia added 2 commits August 10, 2018 10:18
* Creating handleFlowError method
* Using mocks instead of unnecessary spies
Copy link
Contributor

@pfifer pfifer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes.

public void onComplete() {
}
});
Subscriber<ProcessRecordsInput> subscriber = mock(Subscriber.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just make this an instance variable and annotate it with Mock

@pfifer pfifer merged commit 9951062 into awslabs:master Aug 13, 2018
@pfifer pfifer added this to the v2.0.1 milestone Aug 13, 2018
@sahilpalvia sahilpalvia deleted the rnf-fix branch August 13, 2018 16:45
@pfifer pfifer added v2.x Issues related to the 2.x version and removed v2.x Issues related to the 2.x version labels Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2.x Issues related to the 2.x version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants