Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x

This commit is contained in:
Joakim Erdfelt 2017-02-15 11:54:19 -07:00
commit 4eda32ddca
3 changed files with 42 additions and 15 deletions

View File

@ -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);

View File

@ -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))

View File

@ -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;