< prev index next >
src/java.xml.ws/share/classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2015, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 36,45 ****
--- 36,47 ----
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Logger;
+ import java.util.Optional;
+
/**
* Manages all the WebService HTTP servers created by JAXWS runtime.
*
* @author Jitendra Kotamraju
*** 79,88 ****
--- 81,103 ----
InetSocketAddress inetAddress = new InetSocketAddress(url.getHost(),
port);
synchronized(servers) {
state = servers.get(inetAddress);
if (state == null) {
+ final int finalPortNum = port;
+ Optional<ServerState> stateOpt =
+ servers.values()
+ .stream()
+ .filter(s -> s.getServer()
+ .getAddress()
+ .getPort() == finalPortNum)
+ .findAny();
+
+ if (inetAddress.getAddress().isAnyLocalAddress() &&
+ stateOpt.isPresent()) {
+ state = stateOpt.get();
+ } else {
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();
*** 99,108 ****
--- 114,124 ----
state = new ServerState(server, path);
servers.put(inetAddress, state);
return context;
}
}
+ }
server = state.getServer();
if (state.getPaths().contains(url.getPath())) {
String err = "Context with URL path "+url.getPath()+ " already exists on the server "+server.getAddress();
logger.fine(err);
< prev index next >