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

errorResponseBodySerializer handles strings properly #108

Merged
merged 1 commit into from Aug 3, 2018

Conversation

nmyers322
Copy link
Contributor

fixes #107

@codecov-io
Copy link

codecov-io commented Aug 2, 2018

Codecov Report

Merging #108 into master will decrease coverage by 0.1%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #108      +/-   ##
============================================
- Coverage     91.19%   91.08%   -0.11%     
+ Complexity     2138     2137       -1     
============================================
  Files           150      150              
  Lines          6179     6182       +3     
  Branches        813      815       +2     
============================================
- Hits           5635     5631       -4     
- Misses          362      369       +7     
  Partials        182      182
Impacted Files Coverage Δ Complexity Δ
...ke/riposte/util/ErrorContractSerializerHelper.java 81.25% <100%> (+4.32%) 7 <4> (+1) ⬆️
...ient/asynchttp/netty/StreamingAsyncHttpClient.java 74.41% <0%> (-1.63%) 46% <0%> (-2%)
...r/handler/ProxyRouterEndpointExecutionHandler.java 61.25% <0%> (-0.63%) 27% <0%> (-1%)
.../com/nike/riposte/server/logging/AccessLogger.java 96.29% <0%> (+1.48%) 48% <0%> (+1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 954c62a...c5161af. Read the comment docs.

@nmyers322 nmyers322 force-pushed the FIX-107 branch 2 times, most recently from c6b338e to f2ff89f Compare August 2, 2018 20:17
@nmyers322
Copy link
Contributor Author

I amended my commit. Is there a way to kickoff a new coverage report?

@nicmunroe
Copy link
Member

It should happen automatically. Looks like Travis had some connectivity issues grabbing dependencies. I retriggered the build. Hopefully when it finishes successfully it'll update the coverage.

@@ -40,7 +40,11 @@ public static ErrorResponseBodySerializer asErrorResponseBodySerializer(ObjectMa
// indicates empty response body payload, so we should return null.
return null;
}
return objectMapper.writeValueAsString(errorResponseBody.bodyToSerialize());
if(errorResponseBody.bodyToSerialize() instanceof CharSequence) {
Copy link
Member

Choose a reason for hiding this comment

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

Pull errorResponseBody.bodyToSerialize() into a variable so we're not calling it multiple times. Although it would be unwise to do something expensive in that method, we can't control how people will use it, so better safe than sorry.

Copy link
Member

Choose a reason for hiding this comment

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

And I guess that would need to be up top, before the null checks. Hmm. Maybe:

Object bodyToSerialize = (errorResponseBody == null) ? null : errorResponseBody.bodyToSerialize();

And then the null check would just become if (bodyToSerialize == null) { ..., and we can use bodyToSerialize later if it passes the null check.

@nmyers322
Copy link
Contributor Author

I have amended the commit once more with the requested changes.

@nicmunroe nicmunroe merged commit f106329 into Nike-Inc:master Aug 3, 2018
@nicmunroe
Copy link
Member

Thank you @nmyers322 !

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

Successfully merging this pull request may close these issues.

ErrorContractSerializerHelper returns serialized string when bodyToSerialize is already a string
3 participants