From 84ca18779b28443d3e89838d923ed9b4c65fec78 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 12 Apr 2002 09:01:35 +0000 Subject: [PATCH] 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 --- .../apache/tools/ant/taskdefs/KeySubst.java | 31 +++++++++++++------ .../tools/ant/taskdefs/ProcessDestroyer.java | 3 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/KeySubst.java b/src/main/org/apache/tools/ant/taskdefs/KeySubst.java index 29ea1ab7d..b6ec34722 100644 --- a/src/main/org/apache/tools/ant/taskdefs/KeySubst.java +++ b/src/main/org/apache/tools/ant/taskdefs/KeySubst.java @@ -72,8 +72,9 @@ import java.util.StringTokenizer; * setKeys method to understand how to do the substitutions. * * @author Jon S. Stevens jon@clearink.com - * - * @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)); diff --git a/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java b/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java index 2f8c9c2e0..5753159d2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java +++ b/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java @@ -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 Processes when the VM exits. * * @author Michael Newcomb + * @since Ant 1.5 */ class ProcessDestroyer extends Thread