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

client tolerates unexpected body #388

Merged
merged 4 commits into from
Feb 20, 2020
Merged

client tolerates unexpected body #388

merged 4 commits into from
Feb 20, 2020

Conversation

ferozco
Copy link
Contributor

@ferozco ferozco commented Feb 20, 2020

Before this PR

If a client received a response but was not expecting one it would throw

After this PR

==COMMIT_MSG==
Clients are tolerant of unexpected response body
==COMMIT_MSG==

Possible downsides?

N/A

@changelog-app
Copy link

changelog-app bot commented Feb 20, 2020

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Clients are tolerant of unexpected response body

Check the box to generate changelog(s)

  • Generate changelog entry

} catch (IOException e) {
throw new SafeRuntimeException("Failed to read from response body", e);
}
input.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's leave a comment describing that void->type is allowed. Is there a quick test we can add?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 I'll add a comment, I already added tests :)

Copy link
Contributor

@iamdanfox iamdanfox left a comment

Choose a reason for hiding this comment

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

Oof yep this would be a super annoying constraint from back-compat perspective!

@bulldozer-bot bulldozer-bot bot merged commit 10b960c into develop Feb 20, 2020
@bulldozer-bot bulldozer-bot bot deleted the fo/tolerant-client branch February 20, 2020 16:49
@svc-autorelease
Copy link
Collaborator

Released 0.9.1

@@ -141,6 +141,18 @@ public void testBlocking_stringToString_throwsWhenResponseBodyIsEmpty() {
.hasMessageContaining("Failed to deserialize response stream. Syntax error?");
}

@Test
public void testBlocking_voidToVoid_doesNotThrowsWhenResponseBodyIsNonEmpty() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: doesNotThrowWhen

} catch (IOException e) {
throw new SafeRuntimeException("Failed to read from response body", e);
}
// We should not fail if a server that previously return nothing starts returning a response
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: grammar is a little funky here

Copy link
Contributor

Choose a reason for hiding this comment

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

was there a bug here previously w.r.t. the missing input.close()? if so, can you add a test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No there was not a bug, it was previously closed by the try-with-resource. It was simply more concise to call close directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants