Skip to content

Commit b1ea80b

Browse files
committed
JAVA-2308: Make sure that getting driver version won't fail with any exception
1 parent b656048 commit b1ea80b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

driver-core/src/main/com/mongodb/connection/ClientMetadataHelper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.bson.codecs.EncoderContext;
2626
import org.bson.io.BasicOutputBuffer;
2727

28-
import java.io.IOException;
2928
import java.net.JarURLConnection;
3029
import java.net.URL;
3130
import java.nio.charset.Charset;
@@ -113,9 +112,11 @@ private static String getDriverVersion() {
113112
JarURLConnection jarURLConnection = (JarURLConnection) jarUrl.openConnection();
114113
Manifest manifest = jarURLConnection.getManifest();
115114
String version = (String) manifest.getMainAttributes().get(new Attributes.Name("Build-Version"));
116-
driverVersion = version;
115+
if (version != null) {
116+
driverVersion = version;
117+
}
117118
}
118-
} catch (IOException e) {
119+
} catch (Exception e) {
119120
// do nothing
120121
}
121122
return driverVersion;

0 commit comments

Comments
 (0)