From 81197f555a134f3d58f7195fa85046db167bd704 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Tue, 1 Mar 2005 23:09:58 +0000 Subject: [PATCH] Get with usetimestamp did not work when local timestamp roughly >= now. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277761 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 2 ++ src/etc/testcases/taskdefs/get.xml | 18 ++++++++++++++++-- .../org/apache/tools/ant/taskdefs/Get.java | 9 +++------ .../org/apache/tools/ant/taskdefs/GetTest.java | 4 ++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index c7dfce9da..8a86a74ac 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -357,6 +357,8 @@ Fixed bugs: * Get with usetimestamp did not work on Java 1.2. +* Get with usetimestamp did not work when local timestamp roughly >= now. + Changes from Ant 1.6.1 to Ant 1.6.2 =================================== diff --git a/src/etc/testcases/taskdefs/get.xml b/src/etc/testcases/taskdefs/get.xml index 74a81d5f2..4ebcf5c3b 100644 --- a/src/etc/testcases/taskdefs/get.xml +++ b/src/etc/testcases/taskdefs/get.xml @@ -37,11 +37,25 @@ - + + + + + + + + + + + + + + + - + diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java index 58e2ae785..c0b769da2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Get.java +++ b/src/main/org/apache/tools/ant/taskdefs/Get.java @@ -160,20 +160,17 @@ public class Get extends Task { if (connection instanceof HttpURLConnection) { HttpURLConnection httpConnection = (HttpURLConnection) connection; + long lastModified = httpConnection.getLastModified(); if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED - //workaround: doesn't work on 1.2 - || (hasTimestamp - && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2) - && timestamp > httpConnection.getLastModified())) { + || (lastModified != 0 && hasTimestamp + && timestamp > lastModified)) { //not modified so no file download. just return //instead and trace out something so the user //doesn't think that the download happened when it //didn't log("Not modified - so not downloaded", logLevel); return false; - // also, if timestamp is roughly >= now, HTTP_NOT_MODIFIED is _not_ - // returned... We may want to remove the 1.2 qualifier above. } // test for 401 result (HTTP only) if (httpConnection.getResponseCode() diff --git a/src/testcases/org/apache/tools/ant/taskdefs/GetTest.java b/src/testcases/org/apache/tools/ant/taskdefs/GetTest.java index 684812ed5..2a3bc55b5 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/GetTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/GetTest.java @@ -64,4 +64,8 @@ public class GetTest extends BuildFileTest { executeTarget("testUseTimestamp"); } + public void testUseTomorrow() { + executeTarget("testUseTomorrow"); + } + }