Browse Source

magicnumbers

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@577263 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 17 years ago
parent
commit
c4a771c03a
5 changed files with 16 additions and 8 deletions
  1. +4
    -0
      src/main/org/apache/tools/ant/taskdefs/Execute.java
  2. +4
    -2
      src/main/org/apache/tools/ant/taskdefs/Get.java
  3. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/JDBCTask.java
  4. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/Jikes.java
  5. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/KeySubst.java

+ 4
- 0
src/main/org/apache/tools/ant/taskdefs/Execute.java View File

@@ -712,6 +712,7 @@ public class Execute {
HashMap logicals = new HashMap();
String logName = null, logValue = null, newLogName;
String line = null;
// CheckStyle:MagicNumber OFF
while ((line = in.readLine()) != null) {
// parse the VMS logicals into required format ("VAR=VAL[,VAL2]")
if (line.startsWith("\t=")) {
@@ -735,6 +736,7 @@ public class Execute {
}
}
}
// CheckStyle:MagicNumber ON
// Since we "look ahead" before adding, there's one last env var.
if (logName != null) {
logicals.put(logName, logValue);
@@ -1115,11 +1117,13 @@ public class Execute {
if (workingDir == null) {
commandDir = project.getBaseDir();
}
// CheckStyle:MagicNumber OFF
String[] newcmd = new String[cmd.length + 3];
newcmd[0] = "perl";
newcmd[1] = antRun;
newcmd[2] = commandDir.getAbsolutePath();
System.arraycopy(cmd, 0, newcmd, 3, cmd.length);
// CheckStyle:MagicNumber ON

return exec(project, newcmd, env);
}


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

@@ -44,6 +44,8 @@ import java.util.Date;
* @ant.task category="network"
*/
public class Get extends Task {
private static final int NUMBER_RETRIES = 3;
private static final int DOTS_PER_LINE = 50;
private static final int BIG_BUFFER_SIZE = 100 * 1024;
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();

@@ -178,7 +180,7 @@ public class Get extends Task {
//course.

InputStream is = null;
for (int i = 0; i < 3; i++) {
for (int i = 0; i < NUMBER_RETRIES; i++) {
//this three attempt trick is to get round quirks in different
//Java implementations. Some of them take a few goes to bind
//property; we ignore the first couple of such failures.
@@ -429,7 +431,7 @@ public class Get extends Task {
*/
public void onTick() {
out.print(".");
if (dots++ > 50) {
if (dots++ > DOTS_PER_LINE) {
out.flush();
dots = 0;
}


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

@@ -92,14 +92,14 @@ public class SQLExampleTask extends JDBCTask {
*/

public abstract class JDBCTask extends Task {
private static final int HASH_TABLE_SIZE = 3;

/**
* Used for caching loaders / driver. This is to avoid
* getting an OutOfMemoryError when calling this task
* multiple times in a row.
*/
private static Hashtable loaderMap = new Hashtable(3);
private static Hashtable loaderMap = new Hashtable(HASH_TABLE_SIZE);

private boolean caching = true;



+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/Jikes.java View File

@@ -39,7 +39,9 @@ import org.apache.tools.ant.util.FileUtils;
* Merged into the class Javac.
*/
public class Jikes {

// There have been reports that 300 files could be compiled
// on a command line so 250 is a conservative approach
private static final int MAX_FILES_ON_COMMAND_LINE = 250;
// CheckStyle:VisibilityModifier OFF - bc
protected JikesOutputParser jop;
protected String command;
@@ -80,10 +82,8 @@ public class Jikes {
// Windows has a 32k limit on total arg size, so
// create a temporary file to store all the arguments

// There have been reports that 300 files could be compiled
// so 250 is a conservative approach
if (myos.toLowerCase().indexOf("windows") >= 0
&& args.length > 250) {
&& args.length > MAX_FILES_ON_COMMAND_LINE) {
PrintWriter out = null;
try {
String tempFileName = "jikes"


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

@@ -180,6 +180,7 @@ public class KeySubst extends Task {
int index = 0;
int i = 0;
String key = null;
// CheckStyle:MagicNumber OFF
while ((index = origString.indexOf("${", i)) > -1) {
key = origString.substring(index + 2, origString.indexOf("}",
index + 3));
@@ -193,6 +194,7 @@ public class KeySubst extends Task {
}
i = index + 3 + key.length();
}
// CheckStyle:MagicNumber ON
finalString.append (origString.substring(i));
return finalString.toString();
}


Loading…
Cancel
Save