@@ -75,17 +75,8 @@ protected Future<Connection> doConnectInternal(SqlConnectOptions options, Contex
75
75
} catch (Exception e ) {
76
76
return context .failedFuture (e );
77
77
}
78
- String username = options .getUser ();
79
- String password = options .getPassword ();
80
- String database = options .getDatabase ();
81
78
SocketAddress server = options .getSocketAddress ();
82
- Map <String , String > properties = options .getProperties () != null ? Collections .unmodifiableMap (options .getProperties ()) : null ;
83
- return doConnect (server , context , pgOptions ).flatMap (conn -> {
84
- PgSocketConnection socket = (PgSocketConnection ) conn ;
85
- socket .init ();
86
- return Future .<Connection >future (p -> socket .sendStartupMessage (username , password , database , properties , p ))
87
- .map (conn );
88
- });
79
+ return doConnect (server , context , options );
89
80
}
90
81
91
82
public void cancelRequest (PgConnectOptions options , int processId , int secretKey , Handler <AsyncResult <Void >> handler ) {
@@ -104,26 +95,39 @@ private Future<Connection> doConnect(SocketAddress server, ContextInternal conte
104
95
Future <Connection > connFuture ;
105
96
switch (sslMode ) {
106
97
case DISABLE :
107
- connFuture = doConnect (server , context , false , options );
98
+ connFuture = doConnect (server , options , context , false , options );
108
99
break ;
109
100
case ALLOW :
110
- connFuture = doConnect (server , context ,false , options ).recover (err -> doConnect (server , context ,true , options ));
101
+ connFuture = doConnect (server , options , context ,false , options ).recover (err -> doConnect (server , options , context ,true , options ));
111
102
break ;
112
103
case PREFER :
113
- connFuture = doConnect (server , context ,true , options ).recover (err -> doConnect (server , context ,false , options ));
104
+ connFuture = doConnect (server , options , context ,true , options ).recover (err -> doConnect (server , options , context ,false , options ));
114
105
break ;
115
106
case REQUIRE :
116
107
case VERIFY_CA :
117
108
case VERIFY_FULL :
118
- connFuture = doConnect (server , context , true , options );
109
+ connFuture = doConnect (server , options , context , true , options );
119
110
break ;
120
111
default :
121
112
return context .failedFuture (new IllegalArgumentException ("Unsupported SSL mode" ));
122
113
}
123
114
return connFuture ;
124
115
}
125
116
126
- private Future <Connection > doConnect (SocketAddress server , ContextInternal context , boolean ssl , PgConnectOptions options ) {
117
+ private Future <Connection > doConnect (SocketAddress server , PgConnectOptions connectOptions , ContextInternal context , boolean ssl , PgConnectOptions options ) {
118
+ return doConnect_ (server , connectOptions , context , ssl , options ).flatMap (conn -> {
119
+ String username = options .getUser ();
120
+ String password = options .getPassword ();
121
+ String database = options .getDatabase ();
122
+ Map <String , String > properties = options .getProperties () != null ? Collections .unmodifiableMap (options .getProperties ()) : null ;
123
+ PgSocketConnection socket = (PgSocketConnection ) conn ;
124
+ socket .init ();
125
+ return Future .<Connection >future (p -> socket .sendStartupMessage (username , password , database , properties , p ))
126
+ .map (conn );
127
+ });
128
+ }
129
+
130
+ private Future <Connection > doConnect_ (SocketAddress server , PgConnectOptions connectOptions , ContextInternal context , boolean ssl , PgConnectOptions options ) {
127
131
Future <NetSocket > soFut ;
128
132
try {
129
133
soFut = netClient (options ).connect (server , (String ) null );
0 commit comments