java - Handled exception still being written to stdout -
i'm using jetty server hosting java app. added request timeouts kill requests take long. file logs stdout
(which should empty) started fill interruptedexception
stack traces. like:
java.lang.interruptedexception ...... lower level code-lines of project @ com.mycompany.webapps.mycontroller.mymethod(mycontroller.java:252) @ sun.reflect.generatedmethodaccessor67.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ org.springframework.web.method.support.invocablehandlermethod.invoke(invocablehandlermethod.java:219) @ org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:132) @ org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:104) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:745) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:686) @ org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:80) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:925) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:856) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:920) @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:816) @ javax.servlet.http.httpservlet.service(httpservlet.java:687) @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:801) @ javax.servlet.http.httpservlet.service(httpservlet.java:790) @ org.eclipse.jetty.servlet.servletholder.handle(servletholder.java:738) @ org.eclipse.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1651) @ org.eclipse.jetty.servlets.useragentfilter.dofilter(useragentfilter.java:83) @ org.eclipse.jetty.servlets.gzipfilter.dofilter(gzipfilter.java:310) @ org.eclipse.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1622) @ org.eclipse.jetty.servlet.servlethandler.dohandle(servlethandler.java:549) @ org.eclipse.jetty.server.handler.scopedhandler.handle(scopedhandler.java:143) @ org.eclipse.jetty.security.securityhandler.handle(securityhandler.java:568) @ org.eclipse.jetty.server.session.sessionhandler.dohandle(sessionhandler.java:221) @ org.eclipse.jetty.server.handler.contexthandler.dohandle(contexthandler.java:1111) @ org.eclipse.jetty.servlet.servlethandler.doscope(servlethandler.java:478) @ org.eclipse.jetty.server.session.sessionhandler.doscope(sessionhandler.java:183) @ org.eclipse.jetty.server.handler.contexthandler.doscope(contexthandler.java:1045) @ org.eclipse.jetty.server.handler.scopedhandler.handle(scopedhandler.java:141) @ org.eclipse.jetty.server.handler.contexthandlercollection.handle(contexthandlercollection.java:199) @ org.eclipse.jetty.server.handler.handlercollection.handle(handlercollection.java:109) @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:97) @ org.eclipse.jetty.server.handler.statisticshandler.handle(statisticshandler.java:159) @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:97) @ org.eclipse.jetty.server.server.handle(server.java:462) @ org.eclipse.jetty.server.httpchannel.handle(httpchannel.java:279) @ org.eclipse.jetty.server.httpconnection.onfillable(httpconnection.java:232) @ org.eclipse.jetty.io.abstractconnection$2.run(abstractconnection.java:534) @ org.eclipse.jetty.util.thread.queuedthreadpool.runjob(queuedthreadpool.java:607) @ org.eclipse.jetty.util.thread.queuedthreadpool$3.run(queuedthreadpool.java:536)
so, added try-catch in mymethod
(the highest method under control):
@requestmapping(value = "/myurl/{id}", method = requestmethod.get) @responsebody public responseentity<byte[]> mymethod(final httpservletrequest request, @pathvariable final encodedid id) { try { return serveimagerequest(request, sourceid.getid(), docid.getid(), dimensions.getwidth(), dimensions.getheight()); } catch (exception ex) { log.error(ex.getmessage()); return null; } }
the log
variable logger instance (using log4j
) writes messages dedicated log file (and not stdout
). , still, messages written stdout
. difference they're written log file. can't find reason written stdout
, have avoid since file represents stdout
not have rolling policy.
turns out root issue in 3rd party library catches exception , prints stack trace stdout. this being printed although caught , handled exception.
Comments
Post a Comment