Skip to content

Commit

Permalink
Merge pull request Netflix#137 from ghenkes/logging-fix
Browse files Browse the repository at this point in the history
Report ZuulExceptions through logger in ZuulServletFilter
  • Loading branch information
NiteshKant committed Aug 26, 2015
2 parents fd0a0f6 + db2fbec commit 74060d2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ void init(HttpServletRequest servletRequest, HttpServletResponse servletResponse
void error(ZuulException e) {
RequestContext.getCurrentContext().setThrowable(e);
zuulRunner.error();
e.printStackTrace();
}

public void destroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
Expand All @@ -47,10 +45,9 @@
* Time: 10:44 AM
*/
public class ZuulServlet extends HttpServlet {

private static final long serialVersionUID = -3374242278843351500L;
private ZuulRunner zuulRunner;
private static Logger LOG = LoggerFactory.getLogger(ZuulServlet.class);


@Override
Expand Down Expand Up @@ -146,7 +143,6 @@ void init(HttpServletRequest servletRequest, HttpServletResponse servletResponse
void error(ZuulException e) {
RequestContext.getCurrentContext().setThrowable(e);
zuulRunner.error();
LOG.error(e.getMessage(), e);
}

@RunWith(MockitoJUnitRunner.class)
Expand Down Expand Up @@ -196,7 +192,7 @@ public void testProcessZuulFilter() {
RequestContext.testSetCurrentContext(null);

} catch (Exception e) {
LOG.error(e.getMessage(), e);
e.printStackTrace();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.runners.MockitoJUnitRunner
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

class ErrorResponse extends ZuulFilter {

private static final Logger LOG = LoggerFactory.getLogger(ErrorResponse.class);

@Override
String filterType() {
return 'error'
Expand All @@ -53,6 +57,7 @@ class ErrorResponse extends ZuulFilter {
RequestContext context = RequestContext.currentContext
Throwable ex = context.getThrowable()
try {
LOG.error(ex.getMessage(), ex);
throw ex
} catch (ZuulException e) {
String cause = e.errorCause
Expand Down

0 comments on commit 74060d2

Please sign in to comment.