Merge

Wed, 04 Jan 2017 19:44:23 +0000

author
robm
date
Wed, 04 Jan 2017 19:44:23 +0000
changeset 1308
e99de7f2c787
parent 1306
f64e63a04ab1
parent 1307
9b94b2a51e16
child 1340
3fb6f8ed000d
child 1341
e5cc521294d8

Merge

     1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java	Tue Dec 20 15:24:14 2016 -0800
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java	Wed Jan 04 19:44:23 2017 +0000
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -81,24 +81,37 @@
    1.11              synchronized(servers) {
    1.12                  state = servers.get(inetAddress);
    1.13                  if (state == null) {
    1.14 -                    logger.fine("Creating new HTTP Server at "+inetAddress);
    1.15 -                    // Creates server with default socket backlog
    1.16 -                    server = HttpServer.create(inetAddress, 0);
    1.17 -                    server.setExecutor(Executors.newCachedThreadPool());
    1.18 -                    String path = url.toURI().getPath();
    1.19 -                    logger.fine("Creating HTTP Context at = "+path);
    1.20 -                    HttpContext context = server.createContext(path);
    1.21 -                    server.start();
    1.22 +                    final int finalPortNum = port;
    1.23 +                    for (ServerState s: servers.values()) {
    1.24 +                        if (s.getServer()
    1.25 +                             .getAddress()
    1.26 +                             .getPort() == finalPortNum) {
    1.27 +                            state = s;
    1.28 +                            break;
    1.29 +                        }
    1.30 +                    }
    1.31  
    1.32 -                    // we have to get actual inetAddress from server, which can differ from the original in some cases.
    1.33 -                    // e.g. A port number of zero will let the system pick up an ephemeral port in a bind operation,
    1.34 -                    // or IP: 0.0.0.0 - which is used to monitor network traffic from any valid IP address
    1.35 -                    inetAddress = server.getAddress();
    1.36 +                    if (!inetAddress.getAddress().isAnyLocalAddress() ||
    1.37 +                        state == null) {
    1.38 +                        logger.fine("Creating new HTTP Server at "+inetAddress);
    1.39 +                        // Creates server with default socket backlog
    1.40 +                        server = HttpServer.create(inetAddress, 0);
    1.41 +                        server.setExecutor(Executors.newCachedThreadPool());
    1.42 +                        String path = url.toURI().getPath();
    1.43 +                        logger.fine("Creating HTTP Context at = "+path);
    1.44 +                        HttpContext context = server.createContext(path);
    1.45 +                        server.start();
    1.46  
    1.47 -                    logger.fine("HTTP server started = "+inetAddress);
    1.48 -                    state = new ServerState(server, path);
    1.49 -                    servers.put(inetAddress, state);
    1.50 -                    return context;
    1.51 +                        // we have to get actual inetAddress from server, which can differ from the original in some cases.
    1.52 +                        // e.g. A port number of zero will let the system pick up an ephemeral port in a bind operation,
    1.53 +                        // or IP: 0.0.0.0 - which is used to monitor network traffic from any valid IP address
    1.54 +                        inetAddress = server.getAddress();
    1.55 +
    1.56 +                        logger.fine("HTTP server started = "+inetAddress);
    1.57 +                        state = new ServerState(server, path);
    1.58 +                        servers.put(inetAddress, state);
    1.59 +                        return context;
    1.60 +                    }
    1.61                  }
    1.62              }
    1.63              server = state.getServer();

mercurial