diff --git a/core/src/main/java/org/elasticsearch/Build.java b/core/src/main/java/org/elasticsearch/Build.java index a05a412a870..bef9fafe3ca 100644 --- a/core/src/main/java/org/elasticsearch/Build.java +++ b/core/src/main/java/org/elasticsearch/Build.java @@ -43,8 +43,10 @@ public class Build { final String date; final boolean isSnapshot; + final String esPrefix = "elasticsearch-" + Version.CURRENT; final URL url = getElasticsearchCodebase(); - if (url.toString().endsWith(".jar")) { + final String urlStr = url.toString(); + if (urlStr.startsWith("file:/") && (urlStr.endsWith(esPrefix + ".jar") || urlStr.endsWith(esPrefix + "-SNAPSHOT.jar"))) { try (JarInputStream jar = new JarInputStream(FileSystemUtils.openFileURLStream(url))) { Manifest manifest = jar.getManifest(); shortHash = manifest.getMainAttributes().getValue("Change"); @@ -54,7 +56,7 @@ public class Build { throw new RuntimeException(e); } } else { - // not running from a jar (unit tests, IDE) + // not running from the official elasticsearch jar file (unit tests, IDE, uber client jar, shadiness) shortHash = "Unknown"; date = "Unknown"; isSnapshot = true;