You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2014/09/11 18:47:45 UTC
[1/3] git commit: Stip catching Throwable. Replaced by catch
(Exception e) all over the code (except in DefaultIoFilterChain). See
DIRMINA-941
Repository: mina
Updated Branches:
refs/heads/2.0 1c95e0ddf -> f04184d9f
Stip catching Throwable. Replaced by catch (Exception e) all over the
code (except in DefaultIoFilterChain). See DIRMINA-941
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/232bff32
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/232bff32
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/232bff32
Branch: refs/heads/2.0
Commit: 232bff322f0278f614b8b35545655d94465b9e7a
Parents: 1c95e0d
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Thu Sep 11 17:38:12 2014 +0200
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Thu Sep 11 17:38:12 2014 +0200
----------------------------------------------------------------------
.../mina/core/future/DefaultIoFuture.java | 18 ++++++------
.../core/polling/AbstractPollingIoAcceptor.java | 4 +--
.../polling/AbstractPollingIoConnector.java | 4 +--
.../polling/AbstractPollingIoProcessor.java | 12 ++++----
.../mina/core/service/AbstractIoAcceptor.java | 4 +--
.../core/service/IoServiceListenerSupport.java | 14 ++++-----
.../mina/core/session/AbstractIoSession.java | 12 ++++----
.../mina/filter/buffer/BufferedWriteFilter.java | 24 ++++++++--------
.../mina/filter/codec/ProtocolCodecFilter.java | 30 ++++++++++----------
.../socket/nio/NioDatagramAcceptor.java | 10 +++----
.../mina/transport/vmpipe/VmPipeConnector.java | 8 +++---
.../mina/core/IoServiceListenerSupportTest.java | 12 ++++----
.../executor/ExecutorFilterRegressionTest.java | 4 +--
.../mina/integration/jmx/ObjectMBean.java | 26 ++++++++---------
.../mina/statemachine/StateMachineFactory.java | 4 +--
.../transport/serial/SerialSessionImpl.java | 2 +-
16 files changed, 95 insertions(+), 93 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/main/java/org/apache/mina/core/future/DefaultIoFuture.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/future/DefaultIoFuture.java b/mina-core/src/main/java/org/apache/mina/core/future/DefaultIoFuture.java
index 23043eb..ede8f6a 100644
--- a/mina-core/src/main/java/org/apache/mina/core/future/DefaultIoFuture.java
+++ b/mina-core/src/main/java/org/apache/mina/core/future/DefaultIoFuture.java
@@ -97,7 +97,7 @@ public class DefaultIoFuture implements IoFuture {
waiters++;
try {
// Wait for a notify, or if no notify is called,
- // assume that we have a deadlock and exit the
+ // assume that we have a deadlock and exit the
// loop to check for a potential deadlock.
lock.wait(DEAD_LOCK_CHECK_INTERVAL);
} finally {
@@ -157,10 +157,10 @@ public class DefaultIoFuture implements IoFuture {
}
/**
- * Wait for the Future to be ready. If the requested delay is 0 or
- * negative, this method immediately returns the value of the
- * 'ready' flag.
- * Every 5 second, the wait will be suspended to be able to check if
+ * Wait for the Future to be ready. If the requested delay is 0 or
+ * negative, this method immediately returns the value of the
+ * 'ready' flag.
+ * Every 5 second, the wait will be suspended to be able to check if
* there is a deadlock or not.
*
* @param timeoutMillis The delay we will wait for the Future to be ready
@@ -219,12 +219,12 @@ public class DefaultIoFuture implements IoFuture {
*
*/
private void checkDeadLock() {
- // Only read / write / connect / write future can cause dead lock.
+ // Only read / write / connect / write future can cause dead lock.
if (!(this instanceof CloseFuture || this instanceof WriteFuture || this instanceof ReadFuture || this instanceof ConnectFuture)) {
return;
}
- // Get the current thread stackTrace.
+ // Get the current thread stackTrace.
// Using Thread.currentThread().getStackTrace() is the best solution,
// even if slightly less efficient than doing a new Exception().getStackTrace(),
// as internally, it does exactly the same thing. The advantage of using
@@ -373,8 +373,8 @@ public class DefaultIoFuture implements IoFuture {
private void notifyListener(IoFutureListener l) {
try {
l.operationComplete(this);
- } catch (Throwable t) {
- ExceptionMonitor.getInstance().exceptionCaught(t);
+ } catch (Exception e) {
+ ExceptionMonitor.getInstance().exceptionCaught(e);
}
}
}
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java
index cb123c6..437de82 100644
--- a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java
+++ b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoAcceptor.java
@@ -480,7 +480,7 @@ public abstract class AbstractPollingIoAcceptor<S extends AbstractIoSession, H>
// If the selector has been closed, we can exit the loop
ExceptionMonitor.getInstance().exceptionCaught(cse);
break;
- } catch (Throwable e) {
+ } catch (Exception e) {
ExceptionMonitor.getInstance().exceptionCaught(e);
try {
@@ -630,7 +630,7 @@ public abstract class AbstractPollingIoAcceptor<S extends AbstractIoSession, H>
try {
close(handle);
wakeup(); // wake up again to trigger thread death
- } catch (Throwable e) {
+ } catch (Exception e) {
ExceptionMonitor.getInstance().exceptionCaught(e);
} finally {
cancelledHandles++;
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoConnector.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoConnector.java b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoConnector.java
index 04ff153..3178af4 100644
--- a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoConnector.java
+++ b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoConnector.java
@@ -447,7 +447,7 @@ public abstract class AbstractPollingIoConnector<T extends AbstractIoSession, H>
nHandles++;
}
success = true;
- } catch (Throwable e) {
+ } catch (Exception e) {
connectionRequest.setException(e);
} finally {
if (!success) {
@@ -517,7 +517,7 @@ public abstract class AbstractPollingIoConnector<T extends AbstractIoSession, H>
// If the selector has been closed, we can exit the loop
ExceptionMonitor.getInstance().exceptionCaught(cse);
break;
- } catch (Throwable e) {
+ } catch (Exception e) {
ExceptionMonitor.getInstance().exceptionCaught(e);
try {
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
index 0819b4a..bead516 100644
--- a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
+++ b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
@@ -532,7 +532,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
// Propagate the SESSION_CREATED event up to the chain
IoServiceListenerSupport listeners = ((AbstractIoService) session.getService()).getListeners();
listeners.fireSessionCreated(session);
- } catch (Throwable e) {
+ } catch (Exception e) {
ExceptionMonitor.getInstance().exceptionCaught(e);
try {
@@ -722,7 +722,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
if (ret < 0) {
scheduleRemove(session);
}
- } catch (Throwable e) {
+ } catch (Exception e) {
if (e instanceof IOException) {
if (!(e instanceof PortUnreachableException)
|| !AbstractDatagramSessionConfig.class.isAssignableFrom(config.getClass())
@@ -1161,8 +1161,8 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
// But first, dump a stack trace
ExceptionMonitor.getInstance().exceptionCaught(cse);
break;
- } catch (Throwable t) {
- ExceptionMonitor.getInstance().exceptionCaught(t);
+ } catch (Exception e) {
+ ExceptionMonitor.getInstance().exceptionCaught(e);
try {
Thread.sleep(1000);
@@ -1178,8 +1178,8 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
doDispose();
}
}
- } catch (Throwable t) {
- ExceptionMonitor.getInstance().exceptionCaught(t);
+ } catch (Exception e) {
+ ExceptionMonitor.getInstance().exceptionCaught(e);
} finally {
disposalFuture.setValue(true);
}
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoAcceptor.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoAcceptor.java b/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoAcceptor.java
index 22e5507..e5a7ff4 100644
--- a/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoAcceptor.java
+++ b/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoAcceptor.java
@@ -307,7 +307,7 @@ public abstract class AbstractIoAcceptor extends AbstractIoService implements Io
throw e;
} catch (RuntimeException e) {
throw e;
- } catch (Throwable e) {
+ } catch (Exception e) {
throw new RuntimeIoException("Failed to bind to: " + getLocalAddresses(), e);
}
}
@@ -389,7 +389,7 @@ public abstract class AbstractIoAcceptor extends AbstractIoService implements Io
unbind0(localAddressesCopy);
} catch (RuntimeException e) {
throw e;
- } catch (Throwable e) {
+ } catch (Exception e) {
throw new RuntimeIoException("Failed to unbind from: " + getLocalAddresses(), e);
}
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java b/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java
index 0b04968..c94d54b 100644
--- a/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java
+++ b/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java
@@ -114,7 +114,7 @@ public class IoServiceListenerSupport {
}
/**
- * @return The largest number of managed session since the creation of this
+ * @return The largest number of managed session since the creation of this
* listenerSupport
*/
public int getLargestManagedSessionCount() {
@@ -122,7 +122,7 @@ public class IoServiceListenerSupport {
}
/**
- * @return The total number of sessions managed since the initilization of this
+ * @return The total number of sessions managed since the initilization of this
* ListenerSupport
*/
public long getCumulativeManagedSessionCount() {
@@ -152,7 +152,7 @@ public class IoServiceListenerSupport {
for (IoServiceListener listener : listeners) {
try {
listener.serviceActivated(service);
- } catch (Throwable e) {
+ } catch (Exception e) {
ExceptionMonitor.getInstance().exceptionCaught(e);
}
}
@@ -164,7 +164,7 @@ public class IoServiceListenerSupport {
*/
public void fireServiceDeactivated() {
if (!activated.compareAndSet(true, false)) {
- // The instance is already desactivated
+ // The instance is already desactivated
return;
}
@@ -173,7 +173,7 @@ public class IoServiceListenerSupport {
for (IoServiceListener listener : listeners) {
try {
listener.serviceDeactivated(service);
- } catch (Throwable e) {
+ } catch (Exception e) {
ExceptionMonitor.getInstance().exceptionCaught(e);
}
}
@@ -223,7 +223,7 @@ public class IoServiceListenerSupport {
for (IoServiceListener l : listeners) {
try {
l.sessionCreated(session);
- } catch (Throwable e) {
+ } catch (Exception e) {
ExceptionMonitor.getInstance().exceptionCaught(e);
}
}
@@ -248,7 +248,7 @@ public class IoServiceListenerSupport {
for (IoServiceListener l : listeners) {
try {
l.sessionDestroyed(session);
- } catch (Throwable e) {
+ } catch (Exception e) {
ExceptionMonitor.getInstance().exceptionCaught(e);
}
}
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/main/java/org/apache/mina/core/session/AbstractIoSession.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/session/AbstractIoSession.java b/mina-core/src/main/java/org/apache/mina/core/session/AbstractIoSession.java
index 40a60d8..3c51ea4 100644
--- a/mina-core/src/main/java/org/apache/mina/core/session/AbstractIoSession.java
+++ b/mina-core/src/main/java/org/apache/mina/core/session/AbstractIoSession.java
@@ -884,7 +884,10 @@ public abstract class AbstractIoSession implements IoSession {
}
/**
- * TODO Add method documentation
+ * Increase the number of scheduled write bytes for the session
+ *
+ * @param increment
+ * The number of newly added bytes to write
*/
public final void increaseScheduledWriteBytes(int increment) {
scheduledWriteBytes.addAndGet(increment);
@@ -1215,14 +1218,13 @@ public abstract class AbstractIoSession implements IoSession {
try {
remote = String.valueOf(getRemoteAddress());
- } catch (Throwable t) {
- remote = "Cannot get the remote address informations: " + t.getMessage();
+ } catch (Exception e) {
+ remote = "Cannot get the remote address informations: " + e.getMessage();
}
try {
local = String.valueOf(getLocalAddress());
- } catch (Throwable t) {
- local = "Cannot get the local address informations: " + t.getMessage();
+ } catch (Exception e) {
}
if (getService() instanceof IoAcceptor) {
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/main/java/org/apache/mina/filter/buffer/BufferedWriteFilter.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/filter/buffer/BufferedWriteFilter.java b/mina-core/src/main/java/org/apache/mina/filter/buffer/BufferedWriteFilter.java
index bb63cb4..da7e35d 100644
--- a/mina-core/src/main/java/org/apache/mina/filter/buffer/BufferedWriteFilter.java
+++ b/mina-core/src/main/java/org/apache/mina/filter/buffer/BufferedWriteFilter.java
@@ -34,12 +34,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * An {@link IoFilter} implementation used to buffer outgoing {@link WriteRequest} almost
- * like what {@link BufferedOutputStream} does. Using this filter allows to be less dependent
- * from network latency. It is also useful when a session is generating very small messages
+ * An {@link IoFilter} implementation used to buffer outgoing {@link WriteRequest} almost
+ * like what {@link BufferedOutputStream} does. Using this filter allows to be less dependent
+ * from network latency. It is also useful when a session is generating very small messages
* too frequently and consequently generating unnecessary traffic overhead.
*
- * Please note that it should always be placed before the {@link ProtocolCodecFilter}
+ * Please note that it should always be placed before the {@link ProtocolCodecFilter}
* as it only handles {@link WriteRequest}'s carrying {@link IoBuffer} objects.
*
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
@@ -74,7 +74,7 @@ public final class BufferedWriteFilter extends IoFilterAdapter {
}
/**
- * Constructor which sets buffer size to <code>bufferSize</code>.Uses a default
+ * Constructor which sets buffer size to <code>bufferSize</code>.Uses a default
* instance of {@link ConcurrentHashMap}.
*
* @param bufferSize the new buffer size
@@ -84,12 +84,12 @@ public final class BufferedWriteFilter extends IoFilterAdapter {
}
/**
- * Constructor which sets buffer size to <code>bufferSize</code>. If
- * <code>buffersMap</code> is null then a default instance of {@link ConcurrentHashMap}
+ * Constructor which sets buffer size to <code>bufferSize</code>. If
+ * <code>buffersMap</code> is null then a default instance of {@link ConcurrentHashMap}
* is created else the provided instance is used.
*
* @param bufferSize the new buffer size
- * @param buffersMap the map to use for storing each session buffer
+ * @param buffersMap the map to use for storing each session buffer
*/
public BufferedWriteFilter(int bufferSize, LazyInitializedCacheMap<IoSession, IoBuffer> buffersMap) {
super();
@@ -150,12 +150,12 @@ public final class BufferedWriteFilter extends IoFilterAdapter {
/**
* Writes <code>data</code> {@link IoBuffer} to the <code>buf</code>
* {@link IoBuffer} which buffers write requests for the
- * <code>session</code> {@ link IoSession} until buffer is full
+ * <code>session</code> {@ link IoSession} until buffer is full
* or manually flushed.
*
* @param session the session where buffer will be written
* @param data the data to buffer
- * @param buf the buffer where data will be temporarily written
+ * @param buf the buffer where data will be temporarily written
*/
private void write(IoSession session, IoBuffer data, IoBuffer buf) {
try {
@@ -176,7 +176,7 @@ public final class BufferedWriteFilter extends IoFilterAdapter {
synchronized (buf) {
buf.put(data);
}
- } catch (Throwable e) {
+ } catch (Exception e) {
session.getFilterChain().fireExceptionCaught(e);
}
}
@@ -208,7 +208,7 @@ public final class BufferedWriteFilter extends IoFilterAdapter {
public void flush(IoSession session) {
try {
internalFlush(session.getFilterChain().getNextFilter(this), session, buffersMap.get(session));
- } catch (Throwable e) {
+ } catch (Exception e) {
session.getFilterChain().fireExceptionCaught(e);
}
}
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java b/mina-core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
index fa9c497..b541fbe 100644
--- a/mina-core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
+++ b/mina-core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
@@ -233,12 +233,12 @@ public class ProtocolCodecFilter extends IoFilterAdapter {
decoder.decode(session, in, decoderOut);
// Finish decoding if no exception was thrown.
decoderOut.flush(nextFilter, session);
- } catch (Throwable t) {
+ } catch (Exception e) {
ProtocolDecoderException pde;
- if (t instanceof ProtocolDecoderException) {
- pde = (ProtocolDecoderException) t;
+ if (e instanceof ProtocolDecoderException) {
+ pde = (ProtocolDecoderException) e;
} else {
- pde = new ProtocolDecoderException(t);
+ pde = new ProtocolDecoderException(e);
}
if (pde.getHexdump() == null) {
// Generate a message hex dump
@@ -254,7 +254,7 @@ public class ProtocolCodecFilter extends IoFilterAdapter {
// recoverable and the buffer position has changed.
// We check buffer position additionally to prevent an
// infinite loop.
- if (!(t instanceof RecoverableProtocolDecoderException) || (in.position() == oldPos)) {
+ if (!(e instanceof RecoverableProtocolDecoderException) || (in.position() == oldPos)) {
break;
}
} finally {
@@ -327,14 +327,14 @@ public class ProtocolCodecFilter extends IoFilterAdapter {
// Call the next filter
nextFilter.filterWrite(session, new MessageWriteRequest(writeRequest));
- } catch (Throwable t) {
+ } catch (Exception e) {
ProtocolEncoderException pee;
// Generate the correct exception
- if (t instanceof ProtocolEncoderException) {
- pee = (ProtocolEncoderException) t;
+ if (e instanceof ProtocolEncoderException) {
+ pee = (ProtocolEncoderException) e;
} else {
- pee = new ProtocolEncoderException(t);
+ pee = new ProtocolEncoderException(e);
}
throw pee;
@@ -349,12 +349,12 @@ public class ProtocolCodecFilter extends IoFilterAdapter {
try {
decoder.finishDecode(session, decoderOut);
- } catch (Throwable t) {
+ } catch (Exception e) {
ProtocolDecoderException pde;
- if (t instanceof ProtocolDecoderException) {
- pde = (ProtocolDecoderException) t;
+ if (e instanceof ProtocolDecoderException) {
+ pde = (ProtocolDecoderException) e;
} else {
- pde = new ProtocolDecoderException(t);
+ pde = new ProtocolDecoderException(e);
}
throw pde;
} finally {
@@ -480,7 +480,7 @@ public class ProtocolCodecFilter extends IoFilterAdapter {
try {
encoder.dispose(session);
- } catch (Throwable t) {
+ } catch (Exception e) {
LOGGER.warn("Failed to dispose: " + encoder.getClass().getName() + " (" + encoder + ')');
}
}
@@ -498,7 +498,7 @@ public class ProtocolCodecFilter extends IoFilterAdapter {
try {
decoder.dispose(session);
- } catch (Throwable t) {
+ } catch (Exception e) {
LOGGER.warn("Failed to dispose: " + decoder.getClass().getName() + " (" + decoder + ')');
}
}
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioDatagramAcceptor.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioDatagramAcceptor.java b/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioDatagramAcceptor.java
index 5135897..4e912a9 100644
--- a/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioDatagramAcceptor.java
+++ b/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioDatagramAcceptor.java
@@ -272,8 +272,8 @@ public final class NioDatagramAcceptor extends AbstractIoAcceptor implements Dat
scheduleFlush((NioSession) session);
}
}
- } catch (Throwable t) {
- ExceptionMonitor.getInstance().exceptionCaught(t);
+ } catch (Exception e) {
+ ExceptionMonitor.getInstance().exceptionCaught(e);
}
}
}
@@ -331,8 +331,8 @@ public final class NioDatagramAcceptor extends AbstractIoAcceptor implements Dat
try {
this.getFilterChainBuilder().buildFilterChain(session.getFilterChain());
getListeners().fireSessionCreated(session);
- } catch (Throwable t) {
- ExceptionMonitor.getInstance().exceptionCaught(t);
+ } catch (Exception e) {
+ ExceptionMonitor.getInstance().exceptionCaught(e);
}
return session;
@@ -444,7 +444,7 @@ public final class NioDatagramAcceptor extends AbstractIoAcceptor implements Dat
try {
close(handle);
wakeup(); // wake up again to trigger thread death
- } catch (Throwable e) {
+ } catch (Exception e) {
ExceptionMonitor.getInstance().exceptionCaught(e);
} finally {
nHandles++;
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java b/mina-core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
index 100afcc..6c1f7d6 100644
--- a/mina-core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
+++ b/mina-core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
@@ -110,8 +110,8 @@ public final class VmPipeConnector extends AbstractIoConnector {
// The following sentences don't throw any exceptions.
getListeners().fireSessionCreated(localSession);
idleChecker.addSession(localSession);
- } catch (Throwable t) {
- future.setException(t);
+ } catch (Exception e) {
+ future.setException(e);
return future;
}
@@ -125,8 +125,8 @@ public final class VmPipeConnector extends AbstractIoConnector {
// The following sentences don't throw any exceptions.
entry.getListeners().fireSessionCreated(remoteSession);
idleChecker.addSession(remoteSession);
- } catch (Throwable t) {
- ExceptionMonitor.getInstance().exceptionCaught(t);
+ } catch (Exception e) {
+ ExceptionMonitor.getInstance().exceptionCaught(e);
remoteSession.close(true);
}
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/test/java/org/apache/mina/core/IoServiceListenerSupportTest.java
----------------------------------------------------------------------
diff --git a/mina-core/src/test/java/org/apache/mina/core/IoServiceListenerSupportTest.java b/mina-core/src/test/java/org/apache/mina/core/IoServiceListenerSupportTest.java
index c1f62c4..03ae371 100644
--- a/mina-core/src/test/java/org/apache/mina/core/IoServiceListenerSupportTest.java
+++ b/mina-core/src/test/java/org/apache/mina/core/IoServiceListenerSupportTest.java
@@ -19,6 +19,11 @@
*/
package org.apache.mina.core;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.net.InetSocketAddress;
import java.net.SocketAddress;
@@ -32,11 +37,6 @@ import org.apache.mina.core.session.DummySession;
import org.easymock.EasyMock;
import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
/**
* Tests {@link IoServiceListenerSupport}.
*
@@ -180,7 +180,7 @@ public class IoServiceListenerSupportTest {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
- //e.printStackTrace();
+ // e.printStackTrace();
}
// This synchronization block is a workaround for
// the visibility problem of simultaneous EasyMock
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java
----------------------------------------------------------------------
diff --git a/mina-core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java b/mina-core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java
index 33e4130..07b6b6a 100644
--- a/mina-core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java
+++ b/mina-core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java
@@ -137,9 +137,9 @@ public class ExecutorFilterRegressionTest {
public void messageReceived(IoSession session, Object message) {
try {
((EventOrderCounter) session).setLastCount((Integer) message);
- } catch (Throwable t) {
+ } catch (Exception e) {
if (this.throwable == null) {
- this.throwable = t;
+ this.throwable = e;
}
}
}
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-integration-jmx/src/main/java/org/apache/mina/integration/jmx/ObjectMBean.java
----------------------------------------------------------------------
diff --git a/mina-integration-jmx/src/main/java/org/apache/mina/integration/jmx/ObjectMBean.java b/mina-integration-jmx/src/main/java/org/apache/mina/integration/jmx/ObjectMBean.java
index 6dbd746..c254aeb 100644
--- a/mina-integration-jmx/src/main/java/org/apache/mina/integration/jmx/ObjectMBean.java
+++ b/mina-integration-jmx/src/main/java/org/apache/mina/integration/jmx/ObjectMBean.java
@@ -154,12 +154,12 @@ public class ObjectMBean<T> implements ModelMBean, MBeanRegistration {
}
public final Object getAttribute(String fqan) throws AttributeNotFoundException, MBeanException,
- ReflectionException {
+ ReflectionException {
try {
return convertValue(source.getClass(), fqan, getAttribute0(fqan), false);
} catch (AttributeNotFoundException e) {
// Do nothing
- } catch (Throwable e) {
+ } catch (Exception e) {
throwMBeanException(e);
}
@@ -176,7 +176,7 @@ public class ObjectMBean<T> implements ModelMBean, MBeanRegistration {
return convertValue(parent.getClass(), getLeafAttributeName(fqan),
getAttribute(source, fqan, pdesc.getPropertyType()), writable);
- } catch (Throwable e) {
+ } catch (Exception e) {
throwMBeanException(e);
}
@@ -184,7 +184,7 @@ public class ObjectMBean<T> implements ModelMBean, MBeanRegistration {
}
public final void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException,
- ReflectionException {
+ ReflectionException {
String aname = attribute.getName();
Object avalue = attribute.getValue();
@@ -192,7 +192,7 @@ public class ObjectMBean<T> implements ModelMBean, MBeanRegistration {
setAttribute0(aname, avalue);
} catch (AttributeNotFoundException e) {
// Do nothing
- } catch (Throwable e) {
+ } catch (Exception e) {
throwMBeanException(e);
}
@@ -207,13 +207,13 @@ public class ObjectMBean<T> implements ModelMBean, MBeanRegistration {
OgnlContext ctx = (OgnlContext) Ognl.createDefaultContext(source);
ctx.setTypeConverter(typeConverter);
Ognl.setValue(aname, ctx, source, e.getValue());
- } catch (Throwable e) {
+ } catch (Exception e) {
throwMBeanException(e);
}
}
public final Object invoke(String name, Object params[], String signature[]) throws MBeanException,
- ReflectionException {
+ ReflectionException {
// Handle synthetic operations first.
if (name.equals("unregisterMBean")) {
@@ -229,7 +229,7 @@ public class ObjectMBean<T> implements ModelMBean, MBeanRegistration {
return convertValue(null, null, invoke0(name, params, signature), false);
} catch (NoSuchMethodException e) {
// Do nothing
- } catch (Throwable e) {
+ } catch (Exception e) {
throwMBeanException(e);
}
@@ -287,7 +287,7 @@ public class ObjectMBean<T> implements ModelMBean, MBeanRegistration {
// No methods matched.
throw new IllegalArgumentException("Failed to find a matching operation: " + name);
- } catch (Throwable e) {
+ } catch (Exception e) {
throwMBeanException(e);
}
@@ -341,7 +341,7 @@ public class ObjectMBean<T> implements ModelMBean, MBeanRegistration {
}
public final void setManagedResource(Object resource, String type) throws InstanceNotFoundException,
- InvalidTargetObjectTypeException, MBeanException {
+ InvalidTargetObjectTypeException, MBeanException {
throw new RuntimeOperationsException(new UnsupportedOperationException());
}
@@ -781,12 +781,12 @@ public class ObjectMBean<T> implements ModelMBean, MBeanRegistration {
private void throwMBeanException(Throwable e) throws MBeanException {
if (e instanceof OgnlException) {
OgnlException ognle = (OgnlException) e;
-
+
if (ognle.getReason() != null) {
throwMBeanException(ognle.getReason());
} else {
String message = ognle.getMessage();
-
+
if (e instanceof NoSuchPropertyException) {
message = "No such property: " + message;
} else if (e instanceof ExpressionSyntaxException) {
@@ -794,7 +794,7 @@ public class ObjectMBean<T> implements ModelMBean, MBeanRegistration {
} else if (e instanceof InappropriateExpressionException) {
message = "Inappropriate expression: " + message;
}
-
+
e = new IllegalArgumentException(message);
e.setStackTrace(ognle.getStackTrace());
}
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-statemachine/src/main/java/org/apache/mina/statemachine/StateMachineFactory.java
----------------------------------------------------------------------
diff --git a/mina-statemachine/src/main/java/org/apache/mina/statemachine/StateMachineFactory.java b/mina-statemachine/src/main/java/org/apache/mina/statemachine/StateMachineFactory.java
index 41207fb..b5f5e58 100644
--- a/mina-statemachine/src/main/java/org/apache/mina/statemachine/StateMachineFactory.java
+++ b/mina-statemachine/src/main/java/org/apache/mina/statemachine/StateMachineFactory.java
@@ -371,7 +371,7 @@ public class StateMachineFactory {
throw new NoSuchMethodException();
}
return (T) m.invoke(annotation);
- } catch (Throwable t) {
+ } catch (Exception e) {
throw new StateMachineCreationException("Could not get parameter '" + name
+ "' from Transition annotation " + transitionClazz);
}
@@ -409,7 +409,7 @@ public class StateMachineFactory {
throw new NoSuchMethodException();
}
return (T) m.invoke(annotation);
- } catch (Throwable t) {
+ } catch (Exception e) {
throw new StateMachineCreationException("Could not get parameter '" + name
+ "' from Transitions annotation " + transitionsclazz);
}
http://git-wip-us.apache.org/repos/asf/mina/blob/232bff32/mina-transport-serial/src/main/java/org/apache/mina/transport/serial/SerialSessionImpl.java
----------------------------------------------------------------------
diff --git a/mina-transport-serial/src/main/java/org/apache/mina/transport/serial/SerialSessionImpl.java b/mina-transport-serial/src/main/java/org/apache/mina/transport/serial/SerialSessionImpl.java
index 789c586..1288133 100644
--- a/mina-transport-serial/src/main/java/org/apache/mina/transport/serial/SerialSessionImpl.java
+++ b/mina-transport-serial/src/main/java/org/apache/mina/transport/serial/SerialSessionImpl.java
@@ -138,7 +138,7 @@ class SerialSessionImpl extends AbstractIoSession implements SerialSession, Seri
try {
getService().getFilterChainBuilder().buildFilterChain(getFilterChain());
serviceListeners.fireSessionCreated(this);
- } catch (Throwable e) {
+ } catch (Exception e) {
getFilterChain().fireExceptionCaught(e);
processor.remove(this);
}
[2/3] git commit: Some more catch (Throwable) replaced by catch
(Exception)
Posted by el...@apache.org.
Some more catch (Throwable) replaced by catch (Exception)
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/404352c4
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/404352c4
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/404352c4
Branch: refs/heads/2.0
Commit: 404352c427a92efb2b80d2e5b7d5bb84693c7a7c
Parents: 232bff3
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Thu Sep 11 17:49:45 2014 +0200
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Thu Sep 11 17:49:45 2014 +0200
----------------------------------------------------------------------
.../core/filterchain/DefaultIoFilterChain.java | 48 ++++++++++++++++----
1 file changed, 38 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/404352c4/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java b/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
index ea2d3ab..8cc582a 100644
--- a/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
+++ b/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
@@ -457,8 +457,11 @@ public class DefaultIoFilterChain implements IoFilterChain {
IoFilter filter = entry.getFilter();
NextFilter nextFilter = entry.getNextFilter();
filter.sessionCreated(nextFilter, session);
- } catch (Throwable e) {
+ } catch (Exception e) {
fireExceptionCaught(e);
+ } catch (Error e) {
+ fireExceptionCaught(e);
+ throw e;
}
}
@@ -471,8 +474,11 @@ public class DefaultIoFilterChain implements IoFilterChain {
IoFilter filter = entry.getFilter();
NextFilter nextFilter = entry.getNextFilter();
filter.sessionOpened(nextFilter, session);
- } catch (Throwable e) {
+ } catch (Exception e) {
+ fireExceptionCaught(e);
+ } catch (Error e) {
fireExceptionCaught(e);
+ throw e;
}
}
@@ -480,8 +486,11 @@ public class DefaultIoFilterChain implements IoFilterChain {
// Update future.
try {
session.getCloseFuture().setClosed();
- } catch (Throwable t) {
- fireExceptionCaught(t);
+ } catch (Exception e) {
+ fireExceptionCaught(e);
+ } catch (Error e) {
+ fireExceptionCaught(e);
+ throw e;
}
// And start the chain.
@@ -508,8 +517,11 @@ public class DefaultIoFilterChain implements IoFilterChain {
IoFilter filter = entry.getFilter();
NextFilter nextFilter = entry.getNextFilter();
filter.sessionIdle(nextFilter, session, status);
- } catch (Throwable e) {
+ } catch (Exception e) {
+ fireExceptionCaught(e);
+ } catch (Error e) {
fireExceptionCaught(e);
+ throw e;
}
}
@@ -526,16 +538,22 @@ public class DefaultIoFilterChain implements IoFilterChain {
IoFilter filter = entry.getFilter();
NextFilter nextFilter = entry.getNextFilter();
filter.messageReceived(nextFilter, session, message);
- } catch (Throwable e) {
+ } catch (Exception e) {
+ fireExceptionCaught(e);
+ } catch (Error e) {
fireExceptionCaught(e);
+ throw e;
}
}
public void fireMessageSent(WriteRequest request) {
try {
request.getFuture().setWritten();
- } catch (Throwable t) {
- fireExceptionCaught(t);
+ } catch (Exception e) {
+ fireExceptionCaught(e);
+ } catch (Error e) {
+ fireExceptionCaught(e);
+ throw e;
}
if (!request.isEncoded()) {
@@ -548,8 +566,11 @@ public class DefaultIoFilterChain implements IoFilterChain {
IoFilter filter = entry.getFilter();
NextFilter nextFilter = entry.getNextFilter();
filter.messageSent(nextFilter, session, writeRequest);
- } catch (Throwable e) {
+ } catch (Exception e) {
fireExceptionCaught(e);
+ } catch (Error e) {
+ fireExceptionCaught(e);
+ throw e;
}
}
@@ -585,9 +606,13 @@ public class DefaultIoFilterChain implements IoFilterChain {
IoFilter filter = entry.getFilter();
NextFilter nextFilter = entry.getNextFilter();
filter.filterWrite(nextFilter, session, writeRequest);
- } catch (Throwable e) {
+ } catch (Exception e) {
writeRequest.getFuture().setException(e);
fireExceptionCaught(e);
+ } catch (Error e) {
+ writeRequest.getFuture().setException(e);
+ fireExceptionCaught(e);
+ throw e;
}
}
@@ -602,6 +627,9 @@ public class DefaultIoFilterChain implements IoFilterChain {
filter.filterClose(nextFilter, session);
} catch (Exception e) {
fireExceptionCaught(e);
+ } catch (Error e) {
+ fireExceptionCaught(e);
+ throw e;
}
}
[3/3] git commit: Added the sessionClosed event in the
IoServiceListener.
Posted by el...@apache.org.
Added the sessionClosed event in the IoServiceListener.
Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/f04184d9
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/f04184d9
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/f04184d9
Branch: refs/heads/2.0
Commit: f04184d9f2ddb9694a38dbd183af7ebcec538e1e
Parents: 404352c
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Thu Sep 11 18:43:35 2014 +0200
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Thu Sep 11 18:43:35 2014 +0200
----------------------------------------------------------------------
.../core/filterchain/DefaultIoFilterChain.java | 4 +++-
.../mina/core/service/AbstractIoService.java | 24 ++++++++++++--------
.../mina/core/service/IoServiceListener.java | 13 +++++++++--
3 files changed, 28 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina/blob/f04184d9/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java b/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
index 8cc582a..87fc8e1 100644
--- a/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
+++ b/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
@@ -502,7 +502,9 @@ public class DefaultIoFilterChain implements IoFilterChain {
IoFilter filter = entry.getFilter();
NextFilter nextFilter = entry.getNextFilter();
filter.sessionClosed(nextFilter, session);
- } catch (Throwable e) {
+ } catch (Exception e) {
+ fireExceptionCaught(e);
+ } catch (Error e) {
fireExceptionCaught(e);
}
}
http://git-wip-us.apache.org/repos/asf/mina/blob/f04184d9/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoService.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoService.java b/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoService.java
index caf7fa6..6a09763 100644
--- a/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoService.java
+++ b/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoService.java
@@ -63,15 +63,15 @@ public abstract class AbstractIoService implements IoService {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractIoService.class);
- /**
+ /**
* The unique number identifying the Service. It's incremented
* for each new IoService created.
*/
private static final AtomicInteger id = new AtomicInteger();
- /**
- * The thread name built from the IoService inherited
- * instance class name and the IoService Id
+ /**
+ * The thread name built from the IoService inherited
+ * instance class name and the IoService Id
**/
private final String threadName;
@@ -90,7 +90,7 @@ public abstract class AbstractIoService implements IoService {
private final boolean createdExecutor;
/**
- * The IoHandler in charge of managing all the I/O Events. It is
+ * The IoHandler in charge of managing all the I/O Events. It is
*/
private IoHandler handler;
@@ -110,19 +110,23 @@ public abstract class AbstractIoService implements IoService {
}
- public void serviceDeactivated(IoService service) {
+ public void serviceDeactivated(IoService service) throws Exception {
+ // Empty handler
+ }
+
+ public void serviceIdle(IoService service, IdleStatus idleStatus) throws Exception {
// Empty handler
}
- public void serviceIdle(IoService service, IdleStatus idleStatus) {
+ public void sessionCreated(IoSession session) throws Exception {
// Empty handler
}
- public void sessionCreated(IoSession session) {
+ public void sessionClosed(IoSession session) throws Exception {
// Empty handler
}
- public void sessionDestroyed(IoSession session) {
+ public void sessionDestroyed(IoSession session) throws Exception {
// Empty handler
}
};
@@ -480,7 +484,7 @@ public abstract class AbstractIoService implements IoService {
* this method instead.
*/
protected void finishSessionInitialization0(IoSession session, IoFuture future) {
- // Do nothing. Extended class might add some specific code
+ // Do nothing. Extended class might add some specific code
}
protected static class ServiceOperationFuture extends DefaultIoFuture {
http://git-wip-us.apache.org/repos/asf/mina/blob/f04184d9/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListener.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListener.java b/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListener.java
index 5c996ae..a504843 100644
--- a/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListener.java
+++ b/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListener.java
@@ -57,9 +57,18 @@ public interface IoServiceListener extends EventListener {
void sessionCreated(IoSession session) throws Exception;
/**
+ * Invoked when a new session is closed by an {@link IoService}.
+ *
+ * @param session
+ * the new session
+ */
+ void sessionClosed(IoSession session) throws Exception;
+
+ /**
* Invoked when a session is being destroyed by an {@link IoService}.
- *
- * @param session the session to be destroyed
+ *
+ * @param session
+ * the session to be destroyed
*/
void sessionDestroyed(IoSession session) throws Exception;
}