@Test public void testTimeoutByDisconnection() throws Exception { testWholeResponse(); nextFilterControl.reset(); Request req1 = new Request(1, new Object(), Long.MAX_VALUE); Request req2 = new Request(2, new Object(), Long.MAX_VALUE); WriteRequest rwr1 = new DefaultWriteRequest(req1); WriteRequest rwr2 = new DefaultWriteRequest(req2); nextFilter.filterWrite(session, new DefaultWriteRequest(req1 .getMessage())); nextFilterControl.setMatcher(matcher); nextFilter.messageSent(session, rwr1); nextFilter.filterWrite(session, new DefaultWriteRequest(req2 .getMessage())); nextFilter.messageSent(session, rwr2); nextFilter.exceptionCaught(session, new RequestTimeoutException(req1)); nextFilterControl.setMatcher(new ExceptionMatcher()); nextFilter.exceptionCaught(session, new RequestTimeoutException(req2)); nextFilter.sessionClosed(session); nextFilterControl.replay(); filter.filterWrite(nextFilter, session, rwr1); filter.messageSent(nextFilter, session, matcher.getLastWriteRequest()); filter.filterWrite(nextFilter, session, rwr2); filter.messageSent(nextFilter, session, matcher.getLastWriteRequest()); filter.sessionClosed(nextFilter, session); nextFilterControl.verify(); assertRequestTimeoutException(req1); assertRequestTimeoutException(req2); }
@Override public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception { Set<Request> unrespondedRequests = getUnrespondedRequestStore(session); List<Request> unrespondedRequestsCopy; synchronized (unrespondedRequests) { unrespondedRequestsCopy = new ArrayList<>( unrespondedRequests); unrespondedRequests.clear(); } for (Request r : unrespondedRequestsCopy) { if (r.getTimeoutFuture().cancel(false)) { r.getTimeoutTask().run(); } } Map<Object, Request> requestStore = getRequestStore(session); synchronized (requestStore) { requestStore.clear(); } nextFilter.sessionClosed(session); }
RequestResponseFilter extends WriteRequestFilter { @Override public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception { Set<Request> unrespondedRequests = getUnrespondedRequestStore(session); List<Request> unrespondedRequestsCopy; synchronized (unrespondedRequests) { unrespondedRequestsCopy = new ArrayList<>( unrespondedRequests); unrespondedRequests.clear(); } for (Request r : unrespondedRequestsCopy) { if (r.getTimeoutFuture().cancel(false)) { r.getTimeoutTask().run(); } } Map<Object, Request> requestStore = getRequestStore(session); synchronized (requestStore) { requestStore.clear(); } nextFilter.sessionClosed(session); } }
RequestResponseFilter extends WriteRequestFilter { @Override public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception { Set<Request> unrespondedRequests = getUnrespondedRequestStore(session); List<Request> unrespondedRequestsCopy; synchronized (unrespondedRequests) { unrespondedRequestsCopy = new ArrayList<>( unrespondedRequests); unrespondedRequests.clear(); } for (Request r : unrespondedRequestsCopy) { if (r.getTimeoutFuture().cancel(false)) { r.getTimeoutTask().run(); } } Map<Object, Request> requestStore = getRequestStore(session); synchronized (requestStore) { requestStore.clear(); } nextFilter.sessionClosed(session); } RequestResponseFilter(final ResponseInspector responseInspector,
            ScheduledExecutorService timeoutScheduler);  RequestResponseFilter(
            ResponseInspectorFactory responseInspectorFactory,
            ScheduledExecutorService timeoutScheduler); }
RequestResponseFilter extends WriteRequestFilter { @Override public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception { Set<Request> unrespondedRequests = getUnrespondedRequestStore(session); List<Request> unrespondedRequestsCopy; synchronized (unrespondedRequests) { unrespondedRequestsCopy = new ArrayList<>( unrespondedRequests); unrespondedRequests.clear(); } for (Request r : unrespondedRequestsCopy) { if (r.getTimeoutFuture().cancel(false)) { r.getTimeoutTask().run(); } } Map<Object, Request> requestStore = getRequestStore(session); synchronized (requestStore) { requestStore.clear(); } nextFilter.sessionClosed(session); } RequestResponseFilter(final ResponseInspector responseInspector,
            ScheduledExecutorService timeoutScheduler);  RequestResponseFilter(
            ResponseInspectorFactory responseInspectorFactory,
            ScheduledExecutorService timeoutScheduler); @Override void onPreAdd(IoFilterChain parent, String name,
            NextFilter nextFilter); @Override void onPostRemove(IoFilterChain parent, String name,
            NextFilter nextFilter); @Override void messageReceived(NextFilter nextFilter, IoSession session,
            Object message); @Override void sessionClosed(NextFilter nextFilter, IoSession session); }
RequestResponseFilter extends WriteRequestFilter { @Override public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception { Set<Request> unrespondedRequests = getUnrespondedRequestStore(session); List<Request> unrespondedRequestsCopy; synchronized (unrespondedRequests) { unrespondedRequestsCopy = new ArrayList<>( unrespondedRequests); unrespondedRequests.clear(); } for (Request r : unrespondedRequestsCopy) { if (r.getTimeoutFuture().cancel(false)) { r.getTimeoutTask().run(); } } Map<Object, Request> requestStore = getRequestStore(session); synchronized (requestStore) { requestStore.clear(); } nextFilter.sessionClosed(session); } RequestResponseFilter(final ResponseInspector responseInspector,
            ScheduledExecutorService timeoutScheduler);  RequestResponseFilter(
            ResponseInspectorFactory responseInspectorFactory,
            ScheduledExecutorService timeoutScheduler); @Override void onPreAdd(IoFilterChain parent, String name,
            NextFilter nextFilter); @Override void onPostRemove(IoFilterChain parent, String name,
            NextFilter nextFilter); @Override void messageReceived(NextFilter nextFilter, IoSession session,
            Object message); @Override void sessionClosed(NextFilter nextFilter, IoSession session);  }