Apply feedback from @rjernst

This commit is contained in:
Simon Willnauer 2016-02-20 17:12:48 -08:00
parent 4f7dd1284f
commit c8e462e5dc
5 changed files with 16 additions and 25 deletions

View File

@ -47,7 +47,7 @@ if (snapshot) {
// we update the version property to reflect if we are building a snapshot or a release build
// we write this back out below to load it in the Build.java which will be shown in rest main action
// to indicate this being a snapshot build or a release build.
version = version+"-SNAPSHOT"
version += "-SNAPSHOT"
props.put("elasticsearch", version);
}

View File

@ -605,10 +605,13 @@ public class Version {
return Version.smallest(this, fromId(major * 1000000 + 99));
}
/**
* The version number
*/
public String number() {
@SuppressForbidden(reason = "System.out.*")
public static void main(String[] args) {
System.out.println("Version: " + Version.CURRENT + ", Build: " + Build.CURRENT.shortHash() + "/" + Build.CURRENT.date() + ", JVM: " + JvmInfo.jvmInfo().version());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(major).append('.').append(minor).append('.').append(revision);
if (isBeta()) {
@ -629,18 +632,6 @@ public class Version {
return sb.toString();
}
@SuppressForbidden(reason = "System.out.*")
public static void main(String[] args) {
System.out.println("Version: " + Version.CURRENT + ", Build: " + Build.CURRENT.shortHash() + "/" + Build.CURRENT.date() + ", JVM: " + JvmInfo.jvmInfo().version());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(number());
return sb.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {

View File

@ -248,7 +248,7 @@ public class RestNodesAction extends AbstractCatAction {
table.addCell("-");
}
table.addCell(node.getVersion().number());
table.addCell(node.getVersion().toString());
table.addCell(info == null ? null : info.getBuild().shortHash());
table.addCell(jvmInfo == null ? null : jvmInfo.version());
table.addCell(fsInfo == null ? null : fsInfo.getTotal().getAvailable());

View File

@ -81,7 +81,7 @@ public class RestMainAction extends BaseRestHandler {
builder.field("name", Node.NODE_NAME_SETTING.get(settings));
builder.field("cluster_name", clusterName.value());
builder.startObject("version")
.field("number", version.number())
.field("number", version.toString())
.field("build_hash", Build.CURRENT.shortHash())
.field("build_date", Build.CURRENT.date())
.field("build_snapshot", Build.CURRENT.isSnapshot())

View File

@ -84,7 +84,7 @@ public class VersionTests extends ESTestCase {
final int iters = scaledRandomIntBetween(100, 1000);
for (int i = 0; i < iters; i++) {
Version version = randomVersion(random());
assertThat(Version.fromString(version.number()), sameInstance(version));
assertThat(Version.fromString(version.toString()), sameInstance(version));
}
}
@ -141,9 +141,9 @@ public class VersionTests extends ESTestCase {
public void testToString() {
// with 2.0.beta we lowercase
assertEquals("2.0.0-beta1", Version.V_2_0_0_beta1.number());
assertEquals("1.4.0.Beta1", Version.V_1_4_0_Beta1.number());
assertEquals("1.4.0", Version.V_1_4_0.number());
assertEquals("2.0.0-beta1", Version.V_2_0_0_beta1.toString());
assertEquals("1.4.0.Beta1", Version.V_1_4_0_Beta1.toString());
assertEquals("1.4.0", Version.V_1_4_0.toString());
}
public void testIsBeta() {
@ -192,7 +192,7 @@ public class VersionTests extends ESTestCase {
assertEquals("Version id " + field.getName() + " does not point to " + constantName, v, Version.fromId(versionId));
assertEquals("Version " + constantName + " does not have correct id", versionId, v.id);
if (v.major >= 2) {
String number = v.number();
String number = v.toString();
if (v.isBeta()) {
number = number.replace("-beta", "_beta");
} else if (v.isRC()) {
@ -200,7 +200,7 @@ public class VersionTests extends ESTestCase {
}
assertEquals("V_" + number.replace('.', '_'), constantName);
} else {
assertEquals("V_" + v.number().replace('.', '_'), constantName);
assertEquals("V_" + v.toString().replace('.', '_'), constantName);
}
// only the latest version for a branch should be a snapshot (ie unreleased)