Browse Source

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
master
Matthew Jason Benson 20 years ago
parent
commit
81197f555a
4 changed files with 25 additions and 8 deletions
  1. +2
    -0
      WHATSNEW
  2. +16
    -2
      src/etc/testcases/taskdefs/get.xml
  3. +3
    -6
      src/main/org/apache/tools/ant/taskdefs/Get.java
  4. +4
    -0
      src/testcases/org/apache/tools/ant/taskdefs/GetTest.java

+ 2
- 0
WHATSNEW View File

@@ -357,6 +357,8 @@ Fixed bugs:


* Get with usetimestamp did not work on Java 1.2. * 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 Changes from Ant 1.6.1 to Ant 1.6.2
=================================== ===================================




+ 16
- 2
src/etc/testcases/taskdefs/get.xml View File

@@ -37,11 +37,25 @@
</fail> </fail>
</target> </target>


<target name="testUseTimestamp">
<target name="testUseTimestamp" depends="-90s,-timestamp" />

<target name="-90s">
<property name="off" value="-90" />
<property name="unit" value="second" />
</target>

<target name="testUseTomorrow" depends="+1d,-timestamp" />

<target name="+1d">
<property name="off" value="1" />
<property name="unit" value="day" />
</target>

<target name="-timestamp">
<property name="pat" value="yyyyMMddHHmm" /> <property name="pat" value="yyyyMMddHHmm" />


<tstamp> <tstamp>
<format property="dt" pattern="${pat}" offset="-90" unit="second" />
<format property="dt" pattern="${pat}" offset="${off}" unit="${unit}" />
</tstamp> </tstamp>


<touch file="get.tmp" datetime="${dt}" pattern="${pat}" /> <touch file="get.tmp" datetime="${dt}" pattern="${pat}" />


+ 3
- 6
src/main/org/apache/tools/ant/taskdefs/Get.java View File

@@ -160,20 +160,17 @@ public class Get extends Task {
if (connection instanceof HttpURLConnection) { if (connection instanceof HttpURLConnection) {
HttpURLConnection httpConnection HttpURLConnection httpConnection
= (HttpURLConnection) connection; = (HttpURLConnection) connection;
long lastModified = httpConnection.getLastModified();
if (httpConnection.getResponseCode() if (httpConnection.getResponseCode()
== HttpURLConnection.HTTP_NOT_MODIFIED == 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 //not modified so no file download. just return
//instead and trace out something so the user //instead and trace out something so the user
//doesn't think that the download happened when it //doesn't think that the download happened when it
//didn't //didn't
log("Not modified - so not downloaded", logLevel); log("Not modified - so not downloaded", logLevel);
return false; 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) // test for 401 result (HTTP only)
if (httpConnection.getResponseCode() if (httpConnection.getResponseCode()


+ 4
- 0
src/testcases/org/apache/tools/ant/taskdefs/GetTest.java View File

@@ -64,4 +64,8 @@ public class GetTest extends BuildFileTest {
executeTarget("testUseTimestamp"); executeTarget("testUseTimestamp");
} }


public void testUseTomorrow() {
executeTarget("testUseTomorrow");
}

} }

Loading…
Cancel
Save