@ -378,7 +378,7 @@ public class RabbitProperties {
return isEnabled ( ) ;
}
Address address = RabbitProperties . this . parsedAddresses . get ( 0 ) ;
return address . secureConnection ;
return address . determineSslEnabled( isEnabled ( ) ) ;
}
public void setEnabled ( boolean enabled ) {
@ -966,27 +966,25 @@ public class RabbitProperties {
private String virtualHost ;
private b oolean secureConnection ;
private B oolean secureConnection ;
private Address ( String input , boolean sslEnabled ) {
input = input . trim ( ) ;
input = trimPrefix ( input , sslEnabled );
input = trimPrefix ( input );
input = parseUsernameAndPassword ( input ) ;
input = parseVirtualHost ( input ) ;
parseHostAndPort ( input );
parseHostAndPort ( input , sslEnabled );
}
private String trimPrefix ( String input , boolean sslEnabled ) {
private String trimPrefix ( String input ) {
if ( input . startsWith ( PREFIX_AMQP_SECURE ) ) {
this . secureConnection = true ;
return input . substring ( PREFIX_AMQP_SECURE . length ( ) ) ;
}
if ( input . startsWith ( PREFIX_AMQP ) ) {
this . secureConnection = false ;
return input . substring ( PREFIX_AMQP . length ( ) ) ;
}
if ( sslEnabled ) {
this . secureConnection = true ;
}
return input ;
}
@ -1016,11 +1014,11 @@ public class RabbitProperties {
return input ;
}
private void parseHostAndPort ( String input ) {
private void parseHostAndPort ( String input , boolean sslEnabled ) {
int portIndex = input . indexOf ( ':' ) ;
if ( portIndex = = - 1 ) {
this . host = input ;
this . port = ( this . secureConnection ) ? DEFAULT_PORT_SECURE : DEFAULT_PORT ;
this . port = ( determineSslEnabled ( sslEnabled ) ) ? DEFAULT_PORT_SECURE : DEFAULT_PORT ;
}
else {
this . host = input . substring ( 0 , portIndex ) ;
@ -1028,6 +1026,10 @@ public class RabbitProperties {
}
}
private boolean determineSslEnabled ( boolean sslEnabled ) {
return ( this . secureConnection ! = null ) ? this . secureConnection : sslEnabled ;
}
}
}