diff options
author | asaha <none@none> | 2017-01-17 09:22:02 -0800 |
---|---|---|
committer | asaha <none@none> | 2017-01-17 09:22:02 -0800 |
commit | e7f1e2752527b33900b0e3485df5be946bc06d22 (patch) | |
tree | fae3b2dcae6d737e63d17b5920d7f3d27706997a | |
parent | b049e54278ea513e271e254caad435784888f65c (diff) | |
parent | 34e2b825ad9719420a5bedf6bf9d323d23bf4697 (diff) | |
download | jdk8u_jaxws-e7f1e2752527b33900b0e3485df5be946bc06d22.tar.gz |
Merge
-rw-r--r-- | src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java index a16ec36b..a579a3c7 100644 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java @@ -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 @@ final class ServerMgr { 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(); - - // 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; + final int finalPortNum = port; + for (ServerState s: servers.values()) { + if (s.getServer() + .getAddress() + .getPort() == finalPortNum) { + state = s; + break; + } + } + + 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(); + + // 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(); |