revert Versions.java and testcase
* as discussed we keep the buildDate in Version.java but deprecate the getBuildDate() method.
* but we keep the new behavior that Configuration.java does not pass the buildDate anymore to the constructor since it we removed it from version.properties
diff --git a/freemarker-core/src/main/java/freemarker/template/Version.java b/freemarker-core/src/main/java/freemarker/template/Version.java
index d66c969..ac25be1 100644
--- a/freemarker-core/src/main/java/freemarker/template/Version.java
+++ b/freemarker-core/src/main/java/freemarker/template/Version.java
@@ -42,6 +42,7 @@
private final String originalStringValue;
private final Boolean gaeCompliant;
+ private final Date buildDate;
private final int intValue;
private volatile String calculatedStringValue; // not final because it's calculated on demand
@@ -115,6 +116,7 @@
intValue = calculateIntValue();
this.gaeCompliant = gaeCompliant;
+ this.buildDate = buildDate;
}
@@ -140,6 +142,7 @@
this.extraInfo = null;
this.gaeCompliant = null;
+ this.buildDate = null;
originalStringValue = null;
}
@@ -149,6 +152,7 @@
this.micro = micro;
this.extraInfo = extraInfo;
this.gaeCompliant = gaeCompatible;
+ this.buildDate = buildDate;
intValue = calculateIntValue();
originalStringValue = null;
}
@@ -225,11 +229,11 @@
}
/**
- * @deprecated will be removed. Always returns <code>null</code>.
+ * @deprecated do not used anymore
* @return The build date if known, or {@code null}.
*/
public Date getBuildDate() {
- return null;
+ return buildDate;
}
/**
@@ -247,6 +251,7 @@
if (hashCode == 0) {
final int prime = 31;
int result = 1;
+ result = prime * result + (buildDate == null ? 0 : buildDate.hashCode());
result = prime * result + (extraInfo == null ? 0 : extraInfo.hashCode());
result = prime * result + (gaeCompliant == null ? 0 : gaeCompliant.hashCode());
result = prime * result + intValue;
@@ -269,6 +274,12 @@
if (other.hashCode() != hashCode()) return false;
+ if (buildDate == null) {
+ if (other.buildDate != null) return false;
+ } else if (!buildDate.equals(other.buildDate)) {
+ return false;
+ }
+
if (extraInfo == null) {
if (other.extraInfo != null) return false;
} else if (!extraInfo.equals(other.extraInfo)) {
diff --git a/freemarker-core/src/test/java/freemarker/template/VersionTest.java b/freemarker-core/src/test/java/freemarker/template/VersionTest.java
index 55b965a..917b96e 100644
--- a/freemarker-core/src/test/java/freemarker/template/VersionTest.java
+++ b/freemarker-core/src/test/java/freemarker/template/VersionTest.java
@@ -47,7 +47,7 @@
assertEquals("1.2.3-beta8", v.toString());
assertEquals("beta8", v.getExtraInfo());
assertTrue(v.isGAECompliant().booleanValue());
- assertNull(v.getBuildDate());
+ assertEquals(new Date(5000), v.getBuildDate());
}
@Test
@@ -63,7 +63,7 @@
assertEquals("2.3.24-rc01-incubating", v.toString());
assertEquals("rc01-incubating", v.getExtraInfo());
assertFalse(v.isGAECompliant().booleanValue());
- assertNull(v.getBuildDate());
+ assertEquals(new Date(5000), v.getBuildDate());
}
@Test
@@ -89,7 +89,7 @@
assertEquals(30, v.getMicro());
assertNull(v.getExtraInfo());
assertTrue(v.isGAECompliant().booleanValue());
- assertNull(v.getBuildDate());
+ assertEquals(new Date(5000), v.getBuildDate());
}
@Test
@@ -147,8 +147,8 @@
assertTrue(v1.hashCode() != v2.hashCode());
v2 = new Version(1, 2, 3, "beta2", null, new Date(5000));
- assertTrue(v1.equals(v2));
- assertTrue(v1.hashCode() == v2.hashCode());
+ assertTrue(!v1.equals(v2));
+ assertTrue(v1.hashCode() != v2.hashCode());
v2 = new Version("1.2.9-beta2");
assertTrue(!v1.equals(v2));