jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Jetty
  • JETTY-838

Excessive logging when server socket is in use (please don't log and throw)

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Trivial Trivial
  • Resolution: Fixed
  • Affects Version/s: 6.1.14
  • Fix Version/s: 7.0.0.RC5, 6.1.20
  • Component/s: None
  • Labels:
    None
  • Environment:
    N/A

Description

When Jetty is started in embedded mode with a server socket that is already in use, the BindException is printed three times. Two of the stack traces originate from AbstractLifeCycle.start and the third from the embedding program.

Logging an exception and then rethrowing it makes error diagnostics harder, as there's extra noise in the logs. These messages cannot easily be turned of without affecting the overall logging of the application, so the user of Jetty is stuck with noisy logs. Error handling code should EITHER log OR throw.

Here's an example:
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at java.net.ServerSocket.<init>(ServerSocket.java:141)
at org.mortbay.jetty.bio.SocketConnector.newServerSocket(SocketConnector.java:80)
at org.mortbay.jetty.bio.SocketConnector.open(SocketConnector.java:73)
at org.mortbay.jetty.AbstractConnector.doStart(AbstractConnector.java:283)
at org.mortbay.jetty.bio.SocketConnector.doStart(SocketConnector.java:147)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.Server.doStart(Server.java:233)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.yahtzeeplayer.web.StartWebServer.main(StartWebServer.java:114)
[WARNING] org.mortbay.log: failed Server@facf0b
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at java.net.ServerSocket.<init>(ServerSocket.java:141)
at org.mortbay.jetty.bio.SocketConnector.newServerSocket(SocketConnector.java:80)
at org.mortbay.jetty.bio.SocketConnector.open(SocketConnector.java:73)
at org.mortbay.jetty.AbstractConnector.doStart(AbstractConnector.java:283)
at org.mortbay.jetty.bio.SocketConnector.doStart(SocketConnector.java:147)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.Server.doStart(Server.java:233)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.yahtzeeplayer.web.StartWebServer.main(StartWebServer.java:114)
Exception in thread "main" java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at java.net.ServerSocket.<init>(ServerSocket.java:141)
at org.mortbay.jetty.bio.SocketConnector.newServerSocket(SocketConnector.java:80)
at org.mortbay.jetty.bio.SocketConnector.open(SocketConnector.java:73)
at org.mortbay.jetty.AbstractConnector.doStart(AbstractConnector.java:283)
at org.mortbay.jetty.bio.SocketConnector.doStart(SocketConnector.java:147)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.Server.doStart(Server.java:233)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.yahtzeeplayer.web.StartWebServer.main(StartWebServer.java:114)

To fix, remove line 56 in AbstractLifeCycle.java: "Log.warn("failed " + this,e);"

Here is a complete list of calls to Log.warn that are accompanied by throwing new exceptions. Ideally, all of these logging statements should be removed:

  • org.mortbay.servlet.CGI.init line 165
  • org.mortbay.jetty.webapp.WebXmlConfiguration.initialize line 297
  • org.mortbay.jetty.security.SslSocketConnector.newServerSocket(String, int, int) line 461
  • org.mortbay.component.AbstractLifeCycle.start() line 56
  • org.mortbay.component.AbstractLifeCycle.start() line 62
  • org.mortbay.component.AbstractLifeCycle.stop() line 84
  • org.mortbay.component.AbstractLifeCycle.stop() line 90
  • org.mortbay.jetty.handler.ContextHandlerCollection.addContext(String, String) line 269
  • org.mortbay.jetty.servlet.Holder.doStart() line 78
  • org.mortbay.jetty.AbstractConnector.Acceptor.run() line 719
  • org.mortbay.jetty.handler.ContextHandler.setResourceBase(String) line 988
  • org.mortbay.jetty.handler.ResourceHandler.setResourceBase(String) line 130

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Greg Wilkins added a comment - 24/Dec/08 6:08 AM

probably can reduce these to just debugs.

But will hold off on this until the future of jetty-7 is decided, so we don't have to do this in 3 branches.

Show
Greg Wilkins added a comment - 24/Dec/08 6:08 AM probably can reduce these to just debugs. But will hold off on this until the future of jetty-7 is decided, so we don't have to do this in 3 branches.
Hide
Permalink
Jan Bartel added a comment - 29/Apr/09 10:08 PM

Time to re-evaluate now the move to eclipse is more complete.

Show
Jan Bartel added a comment - 29/Apr/09 10:08 PM Time to re-evaluate now the move to eclipse is more complete.
Hide
Permalink
Greg Wilkins added a comment - 26/Aug/09 4:15 AM

fixed... better late than never.

Show
Greg Wilkins added a comment - 26/Aug/09 4:15 AM fixed... better late than never.

People

  • Assignee:
    Greg Wilkins
    Reporter:
    Johannes Brodwall
Vote (0)
Watch (0)

Dates

  • Created:
    20/Dec/08 11:26 PM
    Updated:
    26/Aug/09 4:15 AM
    Resolved:
    26/Aug/09 4:15 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.