[JAVA-2229] SocketFactory overridden if `ssl=true` is used in the URI Created: 17/Jun/16 Updated: 19/Oct/16 Resolved: 30/Sep/16 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Configuration |
| Affects Version/s: | 3.2.2 |
| Fix Version/s: | 3.4.0-rc1, 3.4.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Stephane Nicoll | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
Here is a simple test that demonstrates the issue
A call to sslEnabled will reset the factory. |
| Comments |
| Comment by Githook User [ 30/Sep/16 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: The socketFactory should only get a default value based on the sslEnabled property if it wasn't already explicitly set. |
| Comment by Jeffrey Yemin [ 28/Sep/16 ] |
|
Proposed fix here: https://github.com/jyemin/mongo-java-driver/tree/j2229 |
| Comment by Philip Dicke [ 24/Aug/16 ] |
|
I just ran into this exact problem and spent hours debugging to figure out that ssl=true in the URL overwrites your socket factory when you call getMongoClientOptions(). This behavior is completely unexpected. I consider it a bug. |
| Comment by Stephane Nicoll [ 21/Jun/16 ] |
I am confused. At the very least you could avoid overwriting the SocketFactory if the specified ssl flag has the same value as the one it has currently. The example above would work for those who want to enforce SSL via the url or something. What would you break if you implemented that? |
| Comment by Jeffrey Yemin [ 20/Jun/16 ] |
|
Unfortunately, I don't think we can change the current behavior without breaking compatibility. But, note that if the application refrains from setting ssl parameter on the URI at all, it will work as expected: SSL will be enabled, and the configured socket factory will also be used. |
| Comment by Stephane Nicoll [ 17/Jun/16 ] |
|
Hello, It's not a testing issue. It's not impacting me personally: I am working on the Spring Boot project, see this issue for more context. |
| Comment by Jeffrey Yemin [ 17/Jun/16 ] |
|
Hi Stephane, I see that your example is using a mock SocketFactory. Is this bug impacting a production application, or is it a testing issue? Regards, |
| Comment by Stephane Nicoll [ 17/Jun/16 ] |
|
One potential fix would be to only reset the factory when the value of `sslEnabled` actually changes. |