Browse Source

<keysubst> didn't close its streams. I know, this task is so

deprecated we don't even document it, but ...


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272396 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
84ca18779b
2 changed files with 23 additions and 11 deletions
  1. +21
    -10
      src/main/org/apache/tools/ant/taskdefs/KeySubst.java
  2. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java

+ 21
- 10
src/main/org/apache/tools/ant/taskdefs/KeySubst.java View File

@@ -72,8 +72,9 @@ import java.util.StringTokenizer;
* setKeys method to understand how to do the substitutions.
*
* @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a>
*
* @deprecated KeySubst is deprecated. Use Filter + CopyDir instead.
* @since Ant 1.1
* @deprecated KeySubst is deprecated since Ant 1.1. Use Filter + Copy
* instead.
*/
public class KeySubst extends Task {
private File source = null;
@@ -85,7 +86,7 @@ public class KeySubst extends Task {
Do the execution.
*/
public void execute() throws BuildException {
log("!! KeySubst is deprecated. Use Filter + CopyDir instead. !!");
log("!! KeySubst is deprecated. Use Filter + Copy instead. !!");
log("Performing Substitions");
if ( source == null || dest == null ) {
log("Source and destinations must not be null");
@@ -112,12 +113,22 @@ public class KeySubst extends Task {
line = br.readLine();
}
bw.flush();
bw.close();
br.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
} finally {
if (bw != null) {
try {
bw.close();
} catch (IOException e) {}
}
if (bw != null) {
try {
br.close();
} catch (IOException e) {}
}
}
}

/**
Set the source file.
*/
@@ -162,8 +173,6 @@ public class KeySubst extends Task {
String name = itok.nextToken();
String value = itok.nextToken();
// log ( "Name: " + name );
// log ( "Value: " + value );
replacements.put ( name, value );
}
}
@@ -176,7 +185,8 @@ public class KeySubst extends Task {
Hashtable hash = new Hashtable();
hash.put ( "VERSION", "1.0.3" );
hash.put ( "b", "ffff" );
System.out.println ( KeySubst.replace ( "$f ${VERSION} f ${b} jj $", hash ) );
System.out.println ( KeySubst.replace ( "$f ${VERSION} f ${b} jj $",
hash ) );
}catch ( Exception e)
{
e.printStackTrace();
@@ -196,7 +206,8 @@ public class KeySubst extends Task {
int i = 0;
String key = null;
while ((index = origString.indexOf("${", i)) > -1) {
key = origString.substring(index + 2, origString.indexOf("}", index+3));
key = origString.substring(index + 2, origString.indexOf("}",
index+3));
finalString.append (origString.substring(i, index));
if ( keys.containsKey ( key ) ) {
finalString.append (keys.get(key));


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

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -62,6 +62,7 @@ import java.util.Vector;
* Destroys all registered <code>Process</code>es when the VM exits.
*
* @author <a href="mailto:mnewcomb@tacintel.com">Michael Newcomb</a>
* @since Ant 1.5
*/
class ProcessDestroyer
extends Thread


Loading…
Cancel
Save