[JAVA-2308] Driver version check fails when there is another version.properties file in the classpath Created: 13/Sep/16  Updated: 26/Dec/19  Resolved: 14/Sep/16

Status: Closed
Project: Java Driver
Component/s: Connection Management
Affects Version/s: None
Fix Version/s: 3.4.0

Type: Bug Priority: Major - P3
Reporter: Vladimir Dolzhenko Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to JAVA-2266 Implement The MongoDB Handshake Protocol Closed

 Description   

Version: 3.4.0.SNAPSHOT
ClientMetadataHelper tries to get DriverVersion using

Class<InternalStreamConnectionInitializer> clazz = InternalStreamConnectionInitializer.class;
URL versionPropertiesFileURL = clazz.getResource("/version.properties");

but there is another "version.properties" file in classpath - it leads to IllegalArgumentException("Value can not be null") in BsonString constructor.

This prevents any connections from being established to the MongoDB server.



 Comments   
Comment by Githook User [ 15/Sep/16 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-2308: trim driver version string in Gradle build file

Fixes issue where the manifest can not be loaded by older version of Java
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/1fe1848cebb044669a83e4f9f04b9ec0f7e74a56

Comment by Githook User [ 15/Sep/16 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-2308: Improve exception handling getting the driver version from the manifest
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/b78aa3f298baa12954987338afdb85415ccefbfc

Comment by Githook User [ 14/Sep/16 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-2308: Make sure that getting driver version won't fail with any exception
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/b1ea80b6708ca1d54021be798fde7e6b70257d4a

Comment by Githook User [ 14/Sep/16 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-2308: Remove un-used code
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/b65604872886a413fc79dc1e2be2e5960467a5bc

Comment by Githook User [ 14/Sep/16 ]

Author:

{u'name': u'Vladimir Dolzhenko', u'email': u'vladimir.dolzhenko@markit.com'}

Message: JAVA-2308
unable to start MongoClient
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/e670a674c7b1af0f179f3e398784b95d7a5c3344

Comment by Vladimir Dolzhenko [ 13/Sep/16 ]

Thanks @ross.lawley - I proposed another - much proper fix for the issue

Comment by Ross Lawley [ 13/Sep/16 ]

Hi vladimir.dolzhenko@ihsmarkit.com,

Many thanks for the ticket and the pull request. The client handshake code is still in active development. We'll review your suggested fix and update this ticket once its completed.

Ross

Comment by Vladimir Dolzhenko [ 13/Sep/16 ]

the proper solution has to read value from MANIFEST.MF - but the current manifest doesn't have a version

so - smth like

((JarURLConnection)new URL("jar:file:" + InternalStreamConnectionInitializer.class.getProtectionDomain().getCodeSource().getLocation().getPath() + "!/").openConnection()).getManifest().getAttributes("Version")

but it means that build process have to write Version attribute to manifest

Comment by Vladimir Dolzhenko [ 13/Sep/16 ]

git pull request
https://github.com/mongodb/mongo-java-driver/pull/374

Generated at Thu Feb 08 08:56:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.