spring-cloud-sleuth: NullPointerException in TraceWebAspect.markRequestForSpanClosing(TraceWebAspect.java:147)
Using version 1.2.1.RELEASE
Filter that is causing problems:
public class AuthenticationFilter extends GenericFilterBean {
@Override
public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain chain) throws IOException, ServletException {
if (servletRequest.getAttribute(AUTHENTICATED_USER_REQ_ATTRIBUTE) == null) {
final HttpServletResponse response = (HttpServletResponse) servletResponse;
response.sendError(HttpStatus.UNAUTHORIZED.value());
}
chain.doFilter(servletRequest, servletResponse);
}
}
Basically using the response.sendError(HttpStatus.UNAUTHORIZED.value());
causes the error. If I, for example, use response.setStatus
, the NullPointerException doesn’t happen
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 16 (8 by maintainers)
I have one more idea. What you can is
Try starting a span before sending the error. I think the span will be closed for you but try running this a couple of times to see if you don’t get any Sleuth related exceptions.
True… my bad. Thanks a lot!
Great! When will the next version be released?