Browse Source

Check for possible null message and/or null stream.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271846 13f79535-47bb-0310-9956-ffa450edef68
master
Magesh Umasankar 23 years ago
parent
commit
5df6412cd6
1 changed files with 30 additions and 28 deletions
  1. +30
    -28
      src/main/org/apache/tools/ant/listener/AnsiColorLogger.java

+ 30
- 28
src/main/org/apache/tools/ant/listener/AnsiColorLogger.java View File

@@ -231,35 +231,37 @@ public final class AnsiColorLogger extends DefaultLogger {
protected final void printMessage(final String message,
final PrintStream stream,
final int priority) {
if (!colorsSet) {
setColors();
colorsSet = true;
}
if (message != null && stream != null) {
if (!colorsSet) {
setColors();
colorsSet = true;
}

final StringBuffer msg = new StringBuffer(message);
switch (priority) {
case Project.MSG_ERR:
msg.insert(0, errColor);
msg.append(END_COLOR);
break;
case Project.MSG_WARN:
msg.insert(0, warnColor);
msg.append(END_COLOR);
break;
case Project.MSG_INFO:
msg.insert(0, infoColor);
msg.append(END_COLOR);
break;
case Project.MSG_VERBOSE:
msg.insert(0, verboseColor);
msg.append(END_COLOR);
break;
case Project.MSG_DEBUG:
msg.insert(0, debugColor);
msg.append(END_COLOR);
break;
final StringBuffer msg = new StringBuffer(message);
switch (priority) {
case Project.MSG_ERR:
msg.insert(0, errColor);
msg.append(END_COLOR);
break;
case Project.MSG_WARN:
msg.insert(0, warnColor);
msg.append(END_COLOR);
break;
case Project.MSG_INFO:
msg.insert(0, infoColor);
msg.append(END_COLOR);
break;
case Project.MSG_VERBOSE:
msg.insert(0, verboseColor);
msg.append(END_COLOR);
break;
case Project.MSG_DEBUG:
msg.insert(0, debugColor);
msg.append(END_COLOR);
break;
}
final String strmessage = msg.toString();
stream.println(strmessage);
}
final String strmessage = msg.toString();
stream.println(strmessage);
}
}

Loading…
Cancel
Save