From 297918f71923c4bc7782d41c250dc7a830c6b7da Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 15 Jun 2016 13:12:37 +1000 Subject: [PATCH] Issue #641 Use Mongo createIndex instead of deprecated ensureIndex. --- .../nosql/mongodb/MongoSessionIdManager.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java index 5bc7b83d009..ebc017039b0 100644 --- a/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java +++ b/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionIdManager.java @@ -175,12 +175,23 @@ public class MongoSessionIdManager extends AbstractSessionIdManager _server = server; _sessions = sessions; - _sessions.ensureIndex( - BasicDBObjectBuilder.start().add("id",1).get(), - BasicDBObjectBuilder.start().add("unique",true).add("sparse",false).get()); - _sessions.ensureIndex( - BasicDBObjectBuilder.start().add("id",1).add("version",1).get(), - BasicDBObjectBuilder.start().add("unique",true).add("sparse",false).get()); + DBObject idKey = BasicDBObjectBuilder.start().add("id", 1).get(); + _sessions.createIndex(idKey, + BasicDBObjectBuilder.start() + .add("name", "id_1") + .add("ns", _sessions.getFullName()) + .add("sparse", false) + .add("unique", true) + .get()); + + DBObject versionKey = BasicDBObjectBuilder.start().add("id", 1).add("version", 1).get(); + _sessions.createIndex(versionKey, BasicDBObjectBuilder.start() + .add("name", "id_1_version_1") + .add("ns", _sessions.getFullName()) + .add("sparse", false) + .add("unique", true) + .get()); + }