diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java index 1ec2f2eae0e..8f1d16e5a03 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java @@ -1114,8 +1114,10 @@ public class Response implements HttpServletResponse @Override public void setBufferSize(int size) { - if (isCommitted() || getContentCount() > 0) - throw new IllegalStateException("cannot set buffer size when response is committed or written to"); + if (isCommitted()) + throw new IllegalStateException("cannot set buffer size after response is in committed state"); + if (getContentCount() > 0) + throw new IllegalStateException("cannot set buffer size after response has " + getContentCount() + " bytes already written"); if (size < __MIN_BUFFER_SIZE) size = __MIN_BUFFER_SIZE; _out.setBufferSize(size); diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java index 3b838210b42..863c4486ed2 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java @@ -18,6 +18,8 @@ package org.eclipse.jetty.start; +import static org.eclipse.jetty.start.UsageException.ERR_BAD_GRAPH; +import static org.eclipse.jetty.start.UsageException.ERR_BAD_STOP_PROPS; import static org.eclipse.jetty.start.UsageException.ERR_INVOKE_MAIN; import static org.eclipse.jetty.start.UsageException.ERR_NOT_STOPPED; import static org.eclipse.jetty.start.UsageException.ERR_UNKNOWN; @@ -492,19 +494,38 @@ public class Main private void doStop(StartArgs args) { - String stopHost = args.getProperties().getString("STOP.HOST"); - int stopPort = Integer.parseInt(args.getProperties().getString("STOP.PORT")); - String stopKey = args.getProperties().getString("STOP.KEY"); - - if (args.getProperties().getString("STOP.WAIT") != null) + Props.Prop stopHostProp = args.getProperties().getProp("STOP.HOST", true); + Props.Prop stopPortProp = args.getProperties().getProp("STOP.PORT", true); + Props.Prop stopKeyProp = args.getProperties().getProp("STOP.KEY", true); + Props.Prop stopWaitProp = args.getProperties().getProp("STOP.WAIT", true); + + String stopHost = "127.0.0.1"; + int stopPort = -1; + String stopKey = ""; + + if (stopHostProp != null) { - int stopWait = Integer.parseInt(args.getProperties().getString("STOP.WAIT")); + stopHost = stopHostProp.value; + } + + if (stopPortProp != null) + { + stopPort = Integer.parseInt(stopPortProp.value); + } + + if(stopKeyProp != null) + { + stopKey = stopKeyProp.value; + } - stop(stopHost,stopPort,stopKey,stopWait); + if (stopWaitProp != null) + { + int stopWait = Integer.parseInt(stopWaitProp.value); + stop(stopHost, stopPort, stopKey, stopWait); } else { - stop(stopHost,stopPort,stopKey); + stop(stopHost, stopPort, stopKey); } } @@ -522,19 +543,22 @@ public class Main public void stop(String host, int port, String key, int timeout) { if (host==null || host.length()==0) - host="127.0.0.1"; + { + host = "127.0.0.1"; + } try { - if (port <= 0) + if ( (port <= 0) || (port > 65535) ) { - StartLog.error("STOP.PORT system property must be specified"); + System.err.println("STOP.PORT property must be specified with a valid port number"); + usageExit(ERR_BAD_STOP_PROPS); } if (key == null) { key = ""; - StartLog.info("STOP.KEY system property must be specified"); - StartLog.info("Using empty key"); + System.err.println("STOP.KEY property must be specified"); + System.err.println("Using empty key"); } try (Socket s = new Socket(InetAddress.getByName(host),port)) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/UsageException.java b/jetty-start/src/main/java/org/eclipse/jetty/start/UsageException.java index 914533d0128..75f124bd82f 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/UsageException.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/UsageException.java @@ -29,6 +29,7 @@ public class UsageException extends RuntimeException public static final int ERR_NOT_STOPPED = -4; public static final int ERR_BAD_ARG = -5; public static final int ERR_BAD_GRAPH = -6; + public static final int ERR_BAD_STOP_PROPS = -7; public static final int ERR_UNKNOWN = -9; private int exitCode;