removed close method for mongo client. Now the connection pool is

managed by java driver, upgrade mongo-java-driver to 3.12. Deprecated
getUrl method
This commit is contained in:
Roberto Cirillo 2021-03-12 17:24:49 +01:00
parent 2f2ddfad4a
commit 53a52fdc31
6 changed files with 22 additions and 16 deletions

View File

@ -2,6 +2,8 @@
## [v3.1.0-SNAPSHOT] ## [v3.1.0-SNAPSHOT]
* upgrade mongo-java-client to version 3.12.0 * upgrade mongo-java-client to version 3.12.0
* removed close method for mongo client. Now the connection pool is managed by java driver
* deprecated getUrl method
## [v3.0.1-SNAPSHOT] ## [v3.0.1-SNAPSHOT]

View File

@ -8,7 +8,7 @@
</parent> </parent>
<groupId>org.gcube.contentmanagement</groupId> <groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-core</artifactId> <artifactId>storage-manager-core</artifactId>
<version>3.0.1-SNAPSHOT</version> <version>3.1.0-SNAPSHOT</version>
<scm> <scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection> <connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection> <developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>

View File

@ -96,6 +96,7 @@ public RemoteResourceInfo renewTTL(String key);
* *
* @return RemoteResource object * @return RemoteResource object
*/ */
@Deprecated
RemoteResource getUrl(); RemoteResource getUrl();
/** /**

View File

@ -779,6 +779,9 @@ public class MongoIOManager {
} }
public BasicDBObject findMetaCollectionObject(String source) throws UnknownHostException { public BasicDBObject findMetaCollectionObject(String source) throws UnknownHostException {
//set to null in order to perform a query as BasicDBObject and not GridFSObject
db=null;
mongo=null;
DBCollection fileCollection=getConnectionDB(dbName, false).getCollection(Costants.DEFAULT_META_COLLECTION); DBCollection fileCollection=getConnectionDB(dbName, false).getCollection(Costants.DEFAULT_META_COLLECTION);
BasicDBObject query = new BasicDBObject(); BasicDBObject query = new BasicDBObject();
BasicDBObject obj=null; BasicDBObject obj=null;
@ -1048,11 +1051,11 @@ public class MongoIOManager {
* the old close method * the old close method
*/ */
protected void clean() { protected void clean() {
if(mongo!=null) // if(mongo!=null)
mongo.close(); // mongo.close();
mongo=null; // mongo=null;
if(db!=null) // if(db!=null)
db=null; // db=null;
} }
/** /**
@ -1062,12 +1065,12 @@ public class MongoIOManager {
*/ */
public void close() { public void close() {
if(mongo!=null) // if(mongo!=null)
mongo.close(); // mongo.close();
logger.info("Mongo has been closed"); // logger.info("Mongo has been closed");
mongo=null; // mongo=null;
gfs=null; // gfs=null;
db=null; // db=null;
} }
public void removeGFSFile(GridFSDBFile f, ObjectId idF){ public void removeGFSFile(GridFSDBFile f, ObjectId idF){

View File

@ -31,8 +31,8 @@ public class MongoInputStream extends ProxyInputStream{
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (mongo!=null) // if (mongo!=null)
mongo.close(); // mongo.close();
setClosed(true); setClosed(true);
} }
} }

View File

@ -66,8 +66,8 @@ public class MongoOutputStream extends ProxyOutputStream {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
mongo.close(); // mongo.close();
setClosed(true); // setClosed(true);
} }
} }