public HttpConnector getHttpConnector() throws RuntimeException {
        if (selectedConnector == null) {
            try {

                HttpConnectorList httpConnectorList = getHttpConnectors();

                if (httpConnectorList != null && !httpConnectorList.getConnectors().isEmpty()) {
                    List<HttpConnector> connectors = httpConnectorList.getConnectors();
                    Iterator<HttpConnector> iterator = connectors.iterator();
                    while (iterator.hasNext()) {
                        HttpConnector connector = iterator.next();
                        //take secure conns with preference
                        if (connector.isSecure()) {
                            selectedConnector = connector;
                        }
                    }
                    if (selectedConnector == null) {
                        //if not secure,take the first one
                        selectedConnector = connectors.get(0);
                    }
                }

                if (selectedConnector == null) {
                    //pervent logic to go further
                    throw new RuntimeException("No HttpConnector found");
                }
            } catch (Exception e) {
                throw new RuntimeException("Exception during HTTP Connectors discovery: ", e);
            }
        }
        return selectedConnector;
    }
public HttpConnector getHttpConnector ( ) throws RuntimeException { if ( selectedConnector == null ) { try { HttpConnectorList httpConnectorList = getHttpConnectors ( ) ; if ( httpConnectorList != null && ! httpConnectorList . getConnectors ( ) . isEmpty ( ) ) { List < HttpConnector > connectors = httpConnectorList . getConnectors ( ) ; Iterator < HttpConnector > iterator = connectors . iterator ( ) ; while ( iterator . hasNext ( ) ) { HttpConnector connector = iterator . next ( ) ; if ( connector . isSecure ( ) ) { selectedConnector = connector ; } } if ( selectedConnector == null ) { selectedConnector = connectors . get ( 0 ) ; } } if ( selectedConnector == null ) { throw new RuntimeException ( "No HttpConnector found" ) ; } } catch ( Exception e ) { throw new RuntimeException ( "Exception during HTTP Connectors discovery: " , e ) ; } } return selectedConnector ; }
For historical reasons this method never returns null, and instead
throws a RuntimeException.

TODO review all clients of this method to check for null instead of
throwing RuntimeException

@return The selected connector with Secure preference.
@throws RuntimeException if no connector is found for some reason