Browse Source

PR 56873 make sure connection is established when reading last modified

master
Stefan Bodewig 11 years ago
parent
commit
e8b160a938
2 changed files with 13 additions and 1 deletions
  1. +5
    -0
      WHATSNEW
  2. +8
    -1
      src/main/org/apache/tools/ant/types/resources/URLResource.java

+ 5
- 0
WHATSNEW View File

@@ -27,6 +27,11 @@ Fixed bugs:
cannot determine the local hostname.
Bugzilla Report 56593

* URLResource#getLastModified tried to access the connection to the
URL without making sure it was established, potentially leading to
a NullPointerException.
Bugzilla Report 56873

Other changes:
--------------



+ 8
- 1
src/main/org/apache/tools/ant/types/resources/URLResource.java View File

@@ -265,7 +265,14 @@ public class URLResource extends Resource implements URLProvider {
if (!isExists(false)) {
return 0L;
}
return conn.getLastModified();
try {
connect();
long lastModified = conn.getLastModified();
close();
return lastModified;
} catch (IOException e) {
return UNKNOWN_DATETIME;
}
}

/**


Loading…
Cancel
Save