ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject git commit: PR 56873 make sure connection is established when reading last modified
Date Thu, 21 Aug 2014 05:29:08 GMT
Repository: ant
Updated Branches:
  refs/heads/master 0724e3a23 -> e8b160a93


PR 56873 make sure connection is established when reading last modified


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/e8b160a9
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/e8b160a9
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/e8b160a9

Branch: refs/heads/master
Commit: e8b160a938556376457332dad418ccd0df590b2b
Parents: 0724e3a
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Thu Aug 21 07:28:35 2014 +0200
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Thu Aug 21 07:28:44 2014 +0200

----------------------------------------------------------------------
 WHATSNEW                                                    | 5 +++++
 .../org/apache/tools/ant/types/resources/URLResource.java   | 9 ++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/e8b160a9/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index 5894c07..36b9880 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -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:
 --------------
 

http://git-wip-us.apache.org/repos/asf/ant/blob/e8b160a9/src/main/org/apache/tools/ant/types/resources/URLResource.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/URLResource.java b/src/main/org/apache/tools/ant/types/resources/URLResource.java
index 3ad1bd1..ab564ca 100644
--- a/src/main/org/apache/tools/ant/types/resources/URLResource.java
+++ b/src/main/org/apache/tools/ant/types/resources/URLResource.java
@@ -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;
+        }
     }
 
     /**


Mime
View raw message