@@ -70,17 +70,8 @@ protected Future<Connection> doConnectInternal(PgConnectOptions options, Context
7070 } catch (Exception e ) {
7171 return context .failedFuture (e );
7272 }
73- String username = options .getUser ();
74- String password = options .getPassword ();
75- String database = options .getDatabase ();
7673 SocketAddress server = options .getSocketAddress ();
77- Map <String , String > properties = options .getProperties () != null ? Collections .unmodifiableMap (options .getProperties ()) : null ;
78- return doConnect (server , context , options ).flatMap (conn -> {
79- PgSocketConnection socket = (PgSocketConnection ) conn ;
80- socket .init ();
81- return Future .<Connection >future (p -> socket .sendStartupMessage (username , password , database , properties , p ))
82- .map (conn );
83- });
74+ return doConnect (server , context , options );
8475 }
8576
8677 public void cancelRequest (PgConnectOptions options , int processId , int secretKey , Handler <AsyncResult <Void >> handler ) {
@@ -121,6 +112,19 @@ private Future<Connection> doConnect(SocketAddress server, ContextInternal conte
121112 }
122113
123114 private Future <Connection > doConnect (ConnectOptions connectOptions , ContextInternal context , boolean ssl , PgConnectOptions options ) {
115+ return doConnect_ (connectOptions , context , ssl , options ).flatMap (conn -> {
116+ String username = options .getUser ();
117+ String password = options .getPassword ();
118+ String database = options .getDatabase ();
119+ Map <String , String > properties = options .getProperties () != null ? Collections .unmodifiableMap (options .getProperties ()) : null ;
120+ PgSocketConnection socket = (PgSocketConnection ) conn ;
121+ socket .init ();
122+ return Future .<Connection >future (p -> socket .sendStartupMessage (username , password , database , properties , p ))
123+ .map (conn );
124+ });
125+ }
126+
127+ private Future <Connection > doConnect_ (ConnectOptions connectOptions , ContextInternal context , boolean ssl , PgConnectOptions options ) {
124128 Future <NetSocket > soFut ;
125129 try {
126130 soFut = client .connect (connectOptions );
0 commit comments