# HG changeset patch # User robm # Date 1483559063 0 # Node ID e99de7f2c7878aa6a582916d9de5fb85a8b4ead2 # Parent f64e63a04ab1d1e15090f42ae9a73aef8035abfb# Parent 9b94b2a51e1655a581719994a54364ffe2967d9d Merge diff -r f64e63a04ab1 -r e99de7f2c787 src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java Tue Dec 20 15:24:14 2016 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java Wed Jan 04 19:44:23 2017 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,24 +81,37 @@ synchronized(servers) { state = servers.get(inetAddress); if (state == null) { - logger.fine("Creating new HTTP Server at "+inetAddress); - // Creates server with default socket backlog - server = HttpServer.create(inetAddress, 0); - server.setExecutor(Executors.newCachedThreadPool()); - String path = url.toURI().getPath(); - logger.fine("Creating HTTP Context at = "+path); - HttpContext context = server.createContext(path); - server.start(); + final int finalPortNum = port; + for (ServerState s: servers.values()) { + if (s.getServer() + .getAddress() + .getPort() == finalPortNum) { + state = s; + break; + } + } - // we have to get actual inetAddress from server, which can differ from the original in some cases. - // e.g. A port number of zero will let the system pick up an ephemeral port in a bind operation, - // or IP: 0.0.0.0 - which is used to monitor network traffic from any valid IP address - inetAddress = server.getAddress(); + if (!inetAddress.getAddress().isAnyLocalAddress() || + state == null) { + logger.fine("Creating new HTTP Server at "+inetAddress); + // Creates server with default socket backlog + server = HttpServer.create(inetAddress, 0); + server.setExecutor(Executors.newCachedThreadPool()); + String path = url.toURI().getPath(); + logger.fine("Creating HTTP Context at = "+path); + HttpContext context = server.createContext(path); + server.start(); - logger.fine("HTTP server started = "+inetAddress); - state = new ServerState(server, path); - servers.put(inetAddress, state); - return context; + // we have to get actual inetAddress from server, which can differ from the original in some cases. + // e.g. A port number of zero will let the system pick up an ephemeral port in a bind operation, + // or IP: 0.0.0.0 - which is used to monitor network traffic from any valid IP address + inetAddress = server.getAddress(); + + logger.fine("HTTP server started = "+inetAddress); + state = new ServerState(server, path); + servers.put(inetAddress, state); + return context; + } } } server = state.getServer();