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
fix NullPointerException #551
Conversation
...nsion/src/main/java/org/zalando/opentracing/spring/webflux/extension/ErrorSpanDecorator.java
Outdated
Show resolved
Hide resolved
@zeitlinger Is this fixing the NPE on #550 ? |
no, I think it's unrelated. |
Now you need to provide test, to satisfy coverage and let the build pass |
@@ -30,7 +30,8 @@ public void onResponse( | |||
final ServerWebExchange exchange, | |||
final Span span) { | |||
|
|||
if (predicate.test(exchange.getResponse().getStatusCode())) { | |||
HttpStatus statusCode = exchange.getResponse().getStatusCode(); | |||
if (statusCode == null || predicate.test(statusCode)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under which circumstances is the status null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc: The return value may be null if the status code value is outside the HttpStatus enum range, or if there is no default value from the underlying server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it actually happened..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not questioning that it happens. But it's important to know the reason, otherwise it's impossible to judge whether null should be considered an error.
Do we have access to the original, low level status as an integer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The javadoc suggests that it's just a normal case where nobody set a status code yet and there is no default. Doesn't sound like an error to me. Neither does a value out of range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTTP/1.1 mandates presence of status codes, so missing status code seems rather error to me than not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's getRawStatusCode()
exists, maybe verifying based on it would be better. If not present - error, if present but unknown - not an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a server side filter. I don't think absent status code means what you think it means here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raw status also doesn't help
@Nullable
default Integer getRawStatusCode() {
HttpStatus httpStatus = getStatusCode();
return (httpStatus != null ? httpStatus.value() : null);
}
54de9cd
to
28ac0aa
Compare
@fatroom can't get my commit to be signed.. can you help out? |
@zeitlinger I don't have write access to his repo. Tried to sign in #552 but my sign seems not recognised as well by GH? |
👍 |
Anyway as I see there's no checks for signed commits on this repo, so it's just a question of write access to merge it. |
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@zalando.de>
figured out how to sign the commit... |
👍 |
I'm still not convinced that this is the right change to address that issue. Under which circumstances has someone observed the faulty behavior? Client- or server side? Which dependencies were in play? What was the actual response that the user/client received? |
I had this error come up when running an integration test. The Spring Boot WebFlux version was 2.4.2 and the test looked like this:
|
Where exactly did the error occur in this? Can you post the stack trace here? |
Sure, this is the stacktrace:
|
This is the server side that throws and it's the test implementation for Spring WebFlux. This feels like the wrong fix to even more now. |
can you suggest a different fix - or how we should proceed? |
No description provided.