Send connection closed event when a runtime exception occurs.
[xudocci.git] / src / main / java / net / pterodactylus / irc / Connection.java
index 2feaec4..b67b8db 100644 (file)
@@ -148,6 +148,7 @@ public class Connection extends AbstractExecutionThreadService implements Servic
 
        /**
         * Returns the hostname of the remote end of the connection.
+        *
         * @return The remote’s hostname
         */
        public String hostname() {
@@ -156,6 +157,7 @@ public class Connection extends AbstractExecutionThreadService implements Servic
 
        /**
         * Returns the port number of the remote end of the connection.
+        *
         * @return The remote’s port number
         */
        public int port() {
@@ -509,6 +511,9 @@ public class Connection extends AbstractExecutionThreadService implements Servic
                } catch (IOException ioe1) {
                        logger.log(Level.WARNING, "I/O error", ioe1);
                        eventBus.post(new ConnectionClosed(this, ioe1));
+               } catch (RuntimeException re1) {
+                       logger.log(Level.SEVERE, "Runtime error", re1);
+                       eventBus.post(new ConnectionClosed(this, re1));
                } finally {
                        established = false;
                        logger.info("Closing Connection.");