public static boolean reconnectContext ( RedirectException re , CommandContext ctx ) { boolean reconnected = false ; try { ConnectionInfo info = ctx . getConnectionInfo ( ) ; ControllerAddress address = null ; if ( info != null ) { address = info . getControllerAddress ( ) ; } if ( address != null && isHttpsRedirect ( re , address . getProtocol ( ) ) ) { LOG . debug ( "Trying to reconnect an http to http upgrade" ) ; try { ctx . connectController ( ) ; reconnected = true ; } catch ( Exception ex ) { LOG . warn ( "Exception reconnecting" , ex ) ; // Proper https redirect but error. // Ignoring it. } } } catch ( URISyntaxException ex ) { LOG . warn ( "Invalid URI: " , ex ) ; // OK, invalid redirect. } return reconnected ; }
Reconnect the context if the RedirectException is valid .