diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java index e4269558c3069..3291c28b88ca0 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java @@ -421,7 +421,8 @@ private static boolean isSetsidSupported() { /** Token separator regex used to parse Shell tool outputs */ public static final String TOKEN_SEPARATOR_REGEX = WINDOWS ? "[|\n\r]" : "[ \t\n\r\f]"; - + private static final int ERROR_MSG_MAX_LENGTH = 1024 * 1024; + private long interval; // refresh interval in msec private long lastTime; // last time the command was performed final private boolean redirectErrorStream; // merge stdout and stderr @@ -528,6 +529,8 @@ public void run() { while((line != null) && !isInterrupted()) { errMsg.append(line); errMsg.append(System.getProperty("line.separator")); + errMsg.delete(0, (errMsg.length() - ERROR_MSG_MAX_LENGTH < 0) ? 0 + : (errMsg.length() - ERROR_MSG_MAX_LENGTH)); line = errReader.readLine(); } } catch(IOException ioe) {