Changeset 4797 in josm for trunk/src


Ignore:
Timestamp:
2012-01-15T21:42:25+01:00 (12 years ago)
Author:
simon04
Message:

fix #4062 - remotecontrol prints stack trace when it can't bind to the default port

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpServer.java

    r3707 r4797  
    22package org.openstreetmap.josm.io.remotecontrol;
    33
     4import static org.openstreetmap.josm.tools.I18n.tr;
     5
    46import java.io.IOException;
     7import java.net.BindException;
    58import java.net.ServerSocket;
    69import java.net.Socket;
     
    1417 * Taken from YWMS plugin by frsantos.
    1518 */
    16 
    1719public class RemoteControlHttpServer extends Thread {
    1820
     
    2830     * Starts or restarts the HTTP server
    2931     */
    30     public static void restartRemoteControlHttpServer()
    31     {
    32         try
    33         {
    34             if (instance != null)
     32    public static void restartRemoteControlHttpServer() {
     33        try {
     34            if (instance != null) {
    3535                instance.stopServer();
     36            }
    3637
    37             int port = DEFAULT_PORT;
    38             instance = new RemoteControlHttpServer(port);
     38            instance = new RemoteControlHttpServer(DEFAULT_PORT);
    3939            instance.start();
    40         }
    41         catch(IOException ioe)
    42         {
     40        } catch (BindException ex) {
     41            System.err.println(tr("Warning: Cannot start remotecontrol server on port {0}: {1}",
     42                    Integer.toString(DEFAULT_PORT), ex.getLocalizedMessage()));
     43        } catch (IOException ioe) {
    4344            ioe.printStackTrace();
    4445        }
     
    7980                if( !server.isClosed() )
    8081                    se.printStackTrace();
    81             }
     82                }
    8283            catch (IOException ioe)
    8384            {
Note: See TracChangeset for help on using the changeset viewer.