package org.openspaces.admin.internal.support;

import java.io.IOException;
import java.nio.channels.ClosedChannelException;
import java.rmi.ConnectException;

/**
 * @author kimchy
 */
public abstract class NetworkExceptionHelper {

    public static boolean isConnectOrCloseException(Exception e) {
        if (e instanceof ConnectException) {
            if (e.getCause() instanceof ClosedChannelException || e.getCause() instanceof java.net.ConnectException) {
                return true;
            }

            if (e.getCause() instanceof IOException && e.getCause().getMessage().contains("aborted")) {
                return true;
            }
        }
        if (e instanceof IOException) {
            if (e.getMessage().startsWith("Connection reset by peer")) {
                return true;
            }
        }
        return false;
    }
}

@@ -640,32 +640,197 @@
 e;%0A            %7D
+%0A%0A            if (e.getCause() instanceof IOException && e.getCause().getMessage().contains(%22Connection reset by peer%22)) %7B%0A                return true;%0A            %7D
 %0A        %7D%0A     

improve connection close detection