Add more defensive checks when looking for the driver version to avoid NullPointerException in cases where the driver has been re-packaged without a manifest.
@@ -114,11 +114,16 @@ final class ClientMetadataHelper {
if (jarUrl != null) {
JarURLConnection jarURLConnection = (JarURLConnection) jarUrl.openConnection();
Manifest manifest = jarURLConnection.getManifest();
- String version = (String) manifest.getMainAttributes().get(new Attributes.Name("Build-Version"));
+ if (manifest != null) {
+ Attributes mainAttributes = manifest.getMainAttributes();
+ if (mainAttributes != null) {
+ String version = (String) mainAttributes.get(new Attributes.Name("Build-Version"));
if (version != null) {
driverVersion = version;
}
}
+ }
+ }
} catch (IOException e) {
// do nothing
}
