[JAVA-3000] Deprecate Mongo class Created: 29/Sep/18  Updated: 28/Oct/23  Resolved: 04/Oct/18

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: None
Fix Version/s: 3.9.0

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File MongoDB Warning.png    
Issue Links:
Related
related to JAVA-3099 com.mongodb.MongoClient should implem... Closed

 Description   

To simplify the legacy API, the Mongo class should be deprecated.  MongoClient, a subclass of Mongo, was added in 2.10 and all Mongo constructors have been deprecated.  It's time to deprecate Mongo itself so that it can be removed in the next major release.



 Comments   
Comment by Jeffrey Yemin [ 21/Nov/18 ]

OK, I think Eclipse is being a bit too strict here. I've opened JAVA-3099 to try to fix it. Please follow that issue and I'll get you a SNAPSHOT build to test sometime this afternoon.

Comment by Ken Kolano [X] [ 21/Nov/18 ]

Not clear where it may come out when compiling, but it shows up as a warning with Eclipse's code validation (see attached screenshot).

"The method close() from the type Mongo is deprecated"

import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
 
public class MongoDepWarn {
	public MongoDepWarn() {
		MongoClient con = new MongoClient(new MongoClientURI("mongodb://xxxxxxxxxxxxx"));
		con.close();	
	}
}

Comment by Jeffrey Yemin [ 20/Nov/18 ]

Kolano I'm not seeing this when I compile. Even though the close method is implemented in the Mongo class, the MongoClient class is the one that implements java.io.Closeable.

Can you post the compiler warning that you're getting, as well as which version/distribution of javac that you're using to compile?

Comment by Ken Kolano [X] [ 20/Nov/18 ]

This seems to cause the MongoClient objects close() method to be marked as deprecated as well, I believe because it was inherited from Mongo?

Comment by Githook User [ 04/Oct/18 ]

Author:

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

Message: Deprecate DB#getMongo method, as Mongo itself is deprecated

JAVA-3000
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/1eb62e6cd71f81985cbf58150e002b9886404fa8

Comment by Githook User [ 04/Oct/18 ]

Author:

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

Message: Deprecate com.mongodb.Mongo

JAVA-3000
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/9dd70470d968c8dd287fb52ea4b2c880738b0dc5

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