bodewig 02/04/12 01:49:02
Modified: src/main/org/apache/tools/ant/taskdefs Property.java
Log:
<property> didn't close input stream in resource case. Cosmetics.
Revision Changes Path
1.46 +33 -15
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java
Index: Property.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- Property.java 25 Feb 2002 11:03:40 -0000 1.45
+++ Property.java 12 Apr 2002 08:49:02 -0000 1.46
@@ -76,6 +76,7 @@
* @author [EMAIL PROTECTED]
* @author <a href="mailto:[EMAIL PROTECTED]">Sam Ruby</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Glenn McAllister</a>
+ * @since Ant 1.1
*/
public class Property extends Task {
@@ -94,6 +95,9 @@
super();
}
+ /**
+ * @since Ant 1.5
+ */
protected Property(boolean userProperty) {
this.userProperty = userProperty;
}
@@ -129,7 +133,7 @@
public void setPrefix(String prefix) {
this.prefix = prefix;
if (!prefix.endsWith(".")) {
- this.prefix += ".";
+ this.prefix += ".";
}
}
@@ -177,11 +181,12 @@
}
/**
- * @deprecated This was never a supported feature and has been
deprecated without replacement
+ * @deprecated This was never a supported feature and has been
+ * deprecated without replacement
*/
public void setUserProperty(boolean userProperty) {
- log("DEPRECATED: Ignoring request to set user property in Property
task.",
- Project.MSG_WARN);
+ log("DEPRECATED: Ignoring request to set user property in Property"
+ + " task.", Project.MSG_WARN);
}
public String toString() {
@@ -191,18 +196,21 @@
public void execute() throws BuildException {
if (name != null) {
if (value == null && ref == null) {
- throw new BuildException("You must specify value, location
or refid with the name attribute",
+ throw new BuildException("You must specify value, location
or "
+ + "refid with the name attribute",
location);
}
} else {
if (file == null && resource == null && env == null) {
- throw new BuildException("You must specify file, resource or
environment when not using the name attribute",
- location);
+ throw new BuildException("You must specify file, resource or
"
+ + "environment when not using the "
+ + "name attribute", location);
}
}
if (file == null && resource == null && prefix != null) {
- throw new BuildException("Prefix is only valid when loading from
a file or resource", location);
+ throw new BuildException("Prefix is only valid when loading from
"
+ + "a file or resource", location);
}
if ((name != null) && (value != null)) {
@@ -210,15 +218,15 @@
}
if (file != null) {
- loadFile(file);
+ loadFile(file);
}
if (resource != null) {
- loadResource(resource);
+ loadResource(resource);
}
if (env != null) {
- loadEnvironment(env);
+ loadEnvironment(env);
}
if ((name != null) && (ref != null)) {
@@ -255,9 +263,9 @@
protected void loadResource(String name) {
Properties props = new Properties();
log("Resource Loading " + name, Project.MSG_VERBOSE);
+ InputStream is = null;
try {
ClassLoader cL = null;
- InputStream is = null;
if (classpath != null) {
cL = new AntClassLoader(project, classpath);
@@ -279,13 +287,20 @@
}
} catch (IOException ex) {
throw new BuildException(ex, location);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {}
+ }
}
+
}
protected void loadEnvironment( String prefix ) {
Properties props = new Properties();
if (!prefix.endsWith(".")) {
- prefix += ".";
+ prefix += ".";
}
log("Loading Environment " + prefix, Project.MSG_VERBOSE);
Vector osEnv = Execute.getProcEnvironment();
@@ -340,7 +355,8 @@
while (!resolved) {
Vector fragments = new Vector();
Vector propertyRefs = new Vector();
- ProjectHelper.parsePropertyString(value, fragments,
propertyRefs);
+ ProjectHelper.parsePropertyString(value, fragments,
+ propertyRefs);
resolved = true;
if (propertyRefs.size() != 0) {
@@ -352,7 +368,9 @@
if (fragment == null) {
String propertyName = (String)j.nextElement();
if (propertyName.equals(name)) {
- throw new BuildException("Property " + name
+ " was circularly defined.");
+ throw new BuildException("Property " + name
+ + " was circularly "
+ + "defined.");
}
fragment =
getProject().getProperty(propertyName);
if (fragment == null) {
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>