@@ -75,10 +75,11 @@ void repeating_reconnect_failures_should_be_propagated() throws Exception {
7575
7676 // Start the server.
7777 server .start ("Main" , EPHEMERAL_PORT );
78- final int port = server .getServerSocket ().getLocalPort ();
78+ final String serverHost = server .getServerSocket ().getInetAddress ().getHostAddress ();
79+ final int serverPort = server .getServerSocket ().getLocalPort ();
7980
8081 // Initialize the logger context
81- final Configuration config = createConfiguration (port , null );
82+ final Configuration config = createConfiguration (serverHost , serverPort , null );
8283 try (final LoggerContext loggerContext = createStartedLoggerContext (config )) {
8384
8485 // Configure the error handler
@@ -93,7 +94,7 @@ void repeating_reconnect_failures_should_be_propagated() throws Exception {
9394 verifyLoggingFailure (loggerContext , errorHandler );
9495
9596 // Start the server again, and verify the logging success.
96- server .start ("Main" , port );
97+ server .start ("Main" , serverPort );
9798 verifyLoggingSuccess (loggerContext , server , errorHandler );
9899 }
99100 }
@@ -119,9 +120,9 @@ void reconnect_should_fallback_when_there_are_multiple_resolved_hosts() throws E
119120
120121 // Initialize the logger context
121122 final Configuration config = createConfiguration (
122- // Passing an invalid port, since the resolution is supposed to be performed by the mocked host
123- // resolver anyway.
124- 0 , null );
123+ // Passing dummy host & port, since the resolution is supposed to be performed by the mocked
124+ // host resolver anyway.
125+ "localhost" , 0 , null );
125126 try (final LoggerContext loggerContext = createStartedLoggerContext (config )) {
126127
127128 // Configure the error handler
@@ -213,7 +214,9 @@ void key_store_changes_should_be_detected_at_reconfigure(
213214
214215 // Start the 1st server
215216 server1 .start ("1st" , EPHEMERAL_PORT );
216- final int port = server1 .getServerSocket ().getLocalPort ();
217+ final String server1Host =
218+ server1 .getServerSocket ().getInetAddress ().getHostAddress ();
219+ final int server1Port = server1 .getServerSocket ().getLocalPort ();
217220
218221 // Create the configuration transformer to add the `<Ssl>`, `<KeyStore>`, and `<TrustStore>` elements
219222 final BiFunction <
@@ -239,7 +242,8 @@ void key_store_changes_should_be_detected_at_reconfigure(
239242 };
240243
241244 // Initialize the logger context
242- final Configuration config1 = createConfiguration (port , appenderComponentBuilderTransformer );
245+ final Configuration config1 =
246+ createConfiguration (server1Host , server1Port , appenderComponentBuilderTransformer );
243247 try (final LoggerContext loggerContext = createStartedLoggerContext (config1 )) {
244248
245249 // Configure the error handler
@@ -251,7 +255,7 @@ void key_store_changes_should_be_detected_at_reconfigure(
251255
252256 // Stop the 1st server and start the 2nd one (using different SSL configuration!) on the same port
253257 server1 .close ();
254- server2 .start ("2nd" , port );
258+ server2 .start ("2nd" , server1Port );
255259
256260 // Stage the key store files using the 2nd `SSLContext`
257261 Files .write (keyStoreFilePath , Files .readAllBytes (Paths .get (keyStore2Location )));
@@ -283,7 +287,8 @@ void key_store_changes_should_be_detected_at_reconfigure(
283287 //
284288 // Hence, the only way is to programmatically build the very same configuration, twice, and use the 1st
285289 // one for initialization, and the 2nd one for reconfiguration.
286- final Configuration config2 = createConfiguration (port , appenderComponentBuilderTransformer );
290+ final Configuration config2 =
291+ createConfiguration (server1Host , server1Port , appenderComponentBuilderTransformer );
287292 loggerContext .reconfigure (config2 );
288293
289294 // Verify the working state on the 2nd server
@@ -293,6 +298,7 @@ void key_store_changes_should_be_detected_at_reconfigure(
293298 }
294299
295300 private static Configuration createConfiguration (
301+ final String host ,
296302 final int port ,
297303 @ Nullable
298304 final BiFunction <
@@ -310,7 +316,7 @@ private static Configuration createConfiguration(
310316 // Create the appender configuration
311317 final AppenderComponentBuilder appenderComponentBuilder = configBuilder
312318 .newAppender (APPENDER_NAME , "Socket" )
313- .addAttribute ("host" , "localhost" )
319+ .addAttribute ("host" , host )
314320 .addAttribute ("port" , port )
315321 .addAttribute ("ignoreExceptions" , false )
316322 .addAttribute ("reconnectionDelayMillis" , 10 )
0 commit comments