Browse Source

More StringBuffer size checks

master
Gintas Grigelionis 7 years ago
parent
commit
79c8cb54fe
4 changed files with 16 additions and 16 deletions
  1. +4
    -4
      src/main/org/apache/tools/ant/filters/EscapeUnicode.java
  2. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
  3. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Redirector.java
  4. +9
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java

+ 4
- 4
src/main/org/apache/tools/ant/filters/EscapeUnicode.java View File

@@ -82,7 +82,10 @@ public class EscapeUnicode
} }


int ch = -1; int ch = -1;
if (unicodeBuf.length() == 0) {
if (unicodeBuf.length() > 0) {
ch = (int) unicodeBuf.charAt(0);
unicodeBuf.deleteCharAt(0);
} else {
ch = in.read(); ch = in.read();
if (ch != -1) { if (ch != -1) {
char achar = (char) ch; char achar = (char) ch;
@@ -91,9 +94,6 @@ public class EscapeUnicode
ch = '\\'; ch = '\\';
} }
} }
} else {
ch = (int) unicodeBuf.charAt(0);
unicodeBuf.deleteCharAt(0);
} }
return ch; return ch;
} }


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java View File

@@ -615,8 +615,8 @@ public class ExecuteOn extends ExecTask {
if (forwardSlash && fileSeparator != '/') { if (forwardSlash && fileSeparator != '/') {
src = src.replace(fileSeparator, '/'); src = src.replace(fileSeparator, '/');
} }
if (srcFilePos != null && (srcFilePos.getPrefix().length() > 0
|| srcFilePos.getSuffix().length() > 0)) {
if (srcFilePos != null
&& (!srcFilePos.getPrefix().isEmpty() || !srcFilePos.getSuffix().isEmpty())) {
src = srcFilePos.getPrefix() + src + srcFilePos.getSuffix(); src = srcFilePos.getPrefix() + src + srcFilePos.getSuffix();
} }
result[srcIndex + i] = src; result[srcIndex + i] = src;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Redirector.java View File

@@ -561,7 +561,7 @@ public class Redirector {
String line = null; String line = null;
final StringBuffer val = new StringBuffer(); final StringBuffer val = new StringBuffer();
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
if (val.length() != 0) {
if (val.length() > 0) {
val.append(StringUtils.LINE_SEP); val.append(StringUtils.LINE_SEP);
} }
val.append(line); val.append(line);


+ 9
- 9
src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java View File

@@ -436,31 +436,31 @@ public class IPlanetEjbc {
*/ */
protected void checkConfiguration() throws EjbcException { protected void checkConfiguration() throws EjbcException {


String msg = "";
StringBuilder msg = new StringBuilder();


if (stdDescriptor == null) { if (stdDescriptor == null) {
msg += "A standard XML descriptor file must be specified. ";
msg.append("A standard XML descriptor file must be specified. ");
} }
if (iasDescriptor == null) { if (iasDescriptor == null) {
msg += "An iAS-specific XML descriptor file must be specified. ";
msg.append("An iAS-specific XML descriptor file must be specified. ");
} }
if (classpath == null) { if (classpath == null) {
msg += "A classpath must be specified. ";
msg.append("A classpath must be specified. ");
} }
if (parser == null) { if (parser == null) {
msg += "An XML parser must be specified. ";
msg.append("An XML parser must be specified. ");
} }


if (destDirectory == null) { if (destDirectory == null) {
msg += "A destination directory must be specified. ";
msg.append("A destination directory must be specified. ");
} else if (!destDirectory.exists()) { } else if (!destDirectory.exists()) {
msg += "The destination directory specified does not exist. ";
msg.append("The destination directory specified does not exist. ");
} else if (!destDirectory.isDirectory()) { } else if (!destDirectory.isDirectory()) {
msg += "The destination specified is not a directory. ";
msg.append("The destination specified is not a directory. ");
} }


if (msg.length() > 0) { if (msg.length() > 0) {
throw new EjbcException(msg);
throw new EjbcException(msg.toString());
} }
} }




Loading…
Cancel
Save