mirror of https://github.com/apache/nifi.git
NIFI-602: Ensure we read all data from socket after sending 'SHUTDOWN' command
This commit is contained in:
parent
efc862eac8
commit
66f3b7e30f
|
@ -229,7 +229,10 @@ public class RunNiFi {
|
|||
props.load(fis);
|
||||
}
|
||||
|
||||
logger.log(Level.FINE, "Properties: {0}", props);
|
||||
final Map<Object, Object> modified = new HashMap<>(props);
|
||||
modified.remove("secret.key");
|
||||
logger.log(Level.FINE, "Properties: {0}", modified);
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
|
@ -488,12 +491,15 @@ public class RunNiFi {
|
|||
final OutputStream out = socket.getOutputStream();
|
||||
out.write((SHUTDOWN_CMD + " " + secretKey + "\n").getBytes(StandardCharsets.UTF_8));
|
||||
out.flush();
|
||||
out.close();
|
||||
socket.shutdownOutput();
|
||||
|
||||
final InputStream in = socket.getInputStream();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
final String response = reader.readLine();
|
||||
reader.close();
|
||||
int lastChar;
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
while ((lastChar = in.read()) > -1) {
|
||||
sb.append((char) lastChar);
|
||||
}
|
||||
final String response = sb.toString().trim();
|
||||
|
||||
logger.log(Level.FINE, "Received response to SHUTDOWN command: {0}", response);
|
||||
|
||||
|
|
Loading…
Reference in New Issue