You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2019/08/15 12:23:51 UTC

[GitHub] [maven-integration-testing] joakime commented on a change in pull request #46: [MNG-6731] Jetty getLocalPort() returns -1 resulting in build failures

joakime commented on a change in pull request #46: [MNG-6731] Jetty getLocalPort() returns -1 resulting in build failures
URL: https://github.com/apache/maven-integration-testing/pull/46#discussion_r314284271
 
 

 ##########
 File path: core-it-suite/src/test/java/org/apache/maven/it/HttpServer.java
 ##########
 @@ -66,21 +68,20 @@ public void stop()
 
     public int port()
     {
-        return ( (ServerConnector) server.getConnectors()[0] ).getLocalPort();
+        return ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
     }
 
     private Server server( int port )
     {
-
         QueuedThreadPool threadPool = new QueuedThreadPool();
         threadPool.setMaxThreads( 500 );
         Server server = new Server( threadPool );
+        server.setConnectors( new Connector[]{ new ServerConnector( server ) } );
         server.addBean( new ScheduledExecutorScheduler() );
 
-        ServerConnector http = new ServerConnector( server );
-        http.setPort( port );
-        http.setIdleTimeout( 30000 );
-        server.addConnector( http );
+        ServerConnector connector = (ServerConnector) server.getConnectors()[0];
+        connector.setIdleTimeout( 30_000L );
+        connector.setPort( port );
 
 Review comment:
   Why not just do this instead ?
   
   ``` java
   ServerConnector connector = new ServerConnector( server );
   connector.setIdleTimeout( 30_000L );
   connector.setPort( port );
   server.addConnector( connector );
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services