FULL PRODUCT VERSION :
ADDITIONAL OS VERSION INFORMATION :
various Windows Server versions and various WIndows 7 verions too.
EXTRA RELEVANT SYSTEM CONFIGURATION :
For testing you can use this Manifest file :
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.4
Created-By: 1.8.0_65-b17 (Oracle Corporation)
Built-By: CLISSON
Built-Date: 2018-03-09 14:36:30
Implementation-Title: Dachser Labelprint Client
Implementation-Vendor: Dachser Intelligent Logistics
Implementation-Version: 2.0.0
Main-Class: com.dachser.labelprint.client.LabelprintApplication
Class-Path: .
A DESCRIPTION OF THE PROBLEM :
Hi,
We provide our customers with an EXE file embedding a BAT and our application JAR file.
When starting the Java application read its META-INF/MANIFEST.MF file to determine the current running version of the product. This information is stored under key "Implementation-Version". But since Java 8 update 161 we retrieve a null (or empty) string ... we use the java.util.jar package to perform the job (see source code for test case).
Greetings.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1 - create a JAR with the provided Manifest file
2 - run the test case
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
we expect to extract a String with value "2.0.0"
ACTUAL -
we retrieve a null value from method Manifest.getMainAttributes().getValue(String)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
no stacktrace.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
String version = null;
// look the local version in the Java JAR Manifest
InputStream stream = null;
try {
stream = VersionService.class.getClassLoader().getResourceAsStream(JarFile.MANIFEST_NAME);
Manifest manifest = new Manifest(stream);
version = manifest.getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION);
} catch (IOException cause) {
throw new LabelprintException(LabelprintResourceBundle.getInstance().getTranslations().getString("critical.service.version.missing"), cause);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
if (Logger.getRootLogger().isEnabledFor(Level.WARN)) {
Logger.getRootLogger().warn(String.format("could not close stream of manifest file [%s].", JarFile.MANIFEST_NAME), e);
}
}
}
}
// fail if the version number is undetermined
if (StringUtils.isBlank(version)) {
throw new RuntimeException("version is missing");
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
we asked our customers to go back to previous Java update version (before Java 8 update 161). Some of them accepted. But most of them won't. We think about embedding our own JRE version with our product (it's an EXE file carrying our application JAR).