powered by Jive Software

OutOfMemoryExceptions are eaten by ConnectionHandler - easy fix?

Hi,

our OpenFire server died yesterday with OutOfMemoryExceptions. This can happen & is not a big deal. However the jvm process did not die as it should (we would then have automatically restarted it).

I briefly looked into the Source and I think the problem is the exception handling strategy of Apache Mina and the implementation of exceptionCaught in your ConnectionHandler at http://fisheye.igniterealtime.org/browse/openfire/trunk/src/java/org/jivesoftwar e/openfire/nio/ConnectionHandler.java?hb=true (Line 136ff.).

I think the right fix would be for Mina to only catch Exception and not Throwable, but that would break the interface in an incompatible way, so it is not likely to happen.

If I understand the code correctly it catches all Throwables (this includes Errors). In my experience it is good to pass unrecoverable errors such as OutOfMemory up the stack so the VM can shut down as it should.

I never worked with the codebase before, so my point my be naive, but it is possible to rethrow all Errors so that the VM can terminate?

Otherwise it is very hard for monitoring tools working on process level to determine the death of the software and let external recovery logic (process restaring, …) take place.

Thank you for your great work on OpenFire. It is a very useful and lovely product.

Best regards,

Valentin

PS: Here is a stacktrace from the error.log file

2012.12.14 07:32:32 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

  •      at java.util.HashMap.createEntry(HashMap.java:785)*
    
  •      at java.util.HashMap.putForCreate(HashMap.java:447)*
    
  •      at java.util.HashMap.putAllForCreate(HashMap.java:453)*
    
  •      at java.util.HashMap.<init>(HashMap.java:242)*
    
  •      at java.util.PropertyResourceBundle.<init>(PropertyResourceBundle.java:130)*
    
  •      at java.util.ResourceBundle$Control.newBundle(ResourceBundle.java:2446)*
    
  •      at java.util.ResourceBundle.loadBundle(ResourceBundle.java:1424)*
    
  •      at java.util.ResourceBundle.findBundle(ResourceBundle.java:1383)*
    
  •      at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1252)*
    
  •      at java.util.ResourceBundle.getBundle(ResourceBundle.java:805)*
    
  •      at org.jivesoftware.util.LocaleUtils.getLocalizedString(LocaleUtils.java:373)*
    
  •      at org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl.getExtendedInfo(Mult iUserChatServiceImpl.java:1285)*
    
  •      at org.jivesoftware.openfire.disco.IQDiscoInfoHandler.handleIQ(IQDiscoInfoHandler. java:174)*
    
  •      at org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl.process(MultiUserCha tServiceImpl.java:360)*
    
  •      at org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl.processPacket(MultiU serChatServiceImpl.java:314)*
    
  •      at org.jivesoftware.openfire.component.InternalComponentManager$RoutableComponents .process(InternalComponentManager.java:587)*
    
  •      at org.jivesoftware.openfire.spi.RoutingTableImpl.routeToComponent(RoutingTableImp l.java:352)*
    
  •      at org.jivesoftware.openfire.spi.RoutingTableImpl.routePacket(RoutingTableImpl.jav a:237)*
    
  •      at org.jivesoftware.openfire.IQRouter.handle(IQRouter.java:324)*
    
  •      at org.jivesoftware.openfire.IQRouter.route(IQRouter.java:121)*
    
  •      at org.jivesoftware.openfire.spi.PacketRouterImpl.route(PacketRouterImpl.java:76)*
    
  •      at org.jivesoftware.openfire.SessionPacketRouter.route(SessionPacketRouter.java:10 8)*
    
  •      at org.jivesoftware.openfire.SessionPacketRouter.route(SessionPacketRouter.java:69 )*
    
  •      at org.jivesoftware.openfire.multiplex.MultiplexerPacketHandler.route(MultiplexerP acketHandler.java:188)*
    
  •      at org.jivesoftware.openfire.net.MultiplexerStanzaHandler.processRoute(Multiplexer StanzaHandler.java:101)*
    
  •      at org.jivesoftware.openfire.net.MultiplexerStanzaHandler.processUnknowPacket(Mult iplexerStanzaHandler.java:109)*
    
  •      at org.jivesoftware.openfire.net.StanzaHandler.process(StanzaHandler.java:305)*
    
  •      at org.jivesoftware.openfire.net.StanzaHandler.process(StanzaHandler.java:194)*
    
  •      at org.jivesoftware.openfire.nio.ConnectionHandler.messageReceived(ConnectionHandl er.java:169)*
    
  •      at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived (AbstractIoFilterChain.java:570)*
    
  •      at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)*
    
  •      at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilt erChain.java:53)*
    

2012.12.14 07:38:35 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 07:38:35 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 07:38:35 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 07:38:35 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 07:38:35 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 07:38:35 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 07:38:35 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 07:38:35 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 08:15:20 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 08:15:45 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 08:22:05 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 08:22:05 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 08:22:05 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 08:22:55 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 08:22:55 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 08:22:55 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 08:37:35 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 08:37:35 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 08:38:05 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space

2012.12.14 08:38:20 org.jivesoftware.openfire.nio.ConnectionHandler - Java heap space

java.lang.OutOfMemoryError: Java heap space