Skip to content

Commit 6cc3b48

Browse files
committed
JAVA-2336: Deprecate usePowerOf2Sizes in CreateCollectionOptions and suppress any warnings of usage of CreateCollectionOperation.usePowerOf2Sizes
1 parent 0b4a4c1 commit 6cc3b48

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

driver-async/src/main/com/mongodb/async/client/MongoDatabaseImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public void createCollection(final String collectionName, final SingleResultCall
173173
}
174174

175175
@Override
176+
@SuppressWarnings("deprecation")
176177
public void createCollection(final String collectionName, final CreateCollectionOptions createCollectionOptions,
177178
final SingleResultCallback<Void> callback) {
178179
CreateCollectionOperation operation = new CreateCollectionOperation(name, collectionName, writeConcern)

driver-core/src/main/com/mongodb/client/model/CreateCollectionOptions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ public CreateCollectionOptions sizeInBytes(final long sizeInBytes) {
124124
* @return true if the usePowerOf2Sizes allocation strategy is turned on for this collection
125125
* @mongodb.driver.manual reference/command/collMod/#usePowerOf2Sizes usePowerOf2Sizes
126126
* @mongodb.server.release 2.6
127+
* @deprecated As of MongoDB 3.0, power of 2 sizes is ignored by the MongoDB server
127128
*/
129+
@Deprecated
128130
public Boolean isUsePowerOf2Sizes() {
129131
return usePowerOf2Sizes;
130132
}
@@ -136,7 +138,9 @@ public Boolean isUsePowerOf2Sizes() {
136138
* @return this
137139
* @mongodb.driver.manual reference/command/collMod/#usePowerOf2Sizes usePowerOf2Sizes
138140
* @mongodb.server.release 2.6
141+
* @deprecated As of MongoDB 3.0, power of 2 sizes is ignored by the MongoDB server
139142
*/
143+
@Deprecated
140144
public CreateCollectionOptions usePowerOf2Sizes(final Boolean usePowerOf2Sizes) {
141145
this.usePowerOf2Sizes = usePowerOf2Sizes;
142146
return this;

driver-core/src/test/functional/com/mongodb/client/test/CollectionHelper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ public void create(final String collectionName, final CreateCollectionOptions op
108108
.capped(options.isCapped())
109109
.sizeInBytes(options.getSizeInBytes())
110110
.autoIndex(options.isAutoIndex())
111-
.maxDocuments(options.getMaxDocuments())
112-
.usePowerOf2Sizes(options.isUsePowerOf2Sizes());
111+
.maxDocuments(options.getMaxDocuments());
113112

114113
IndexOptionDefaults indexOptionDefaults = options.getIndexOptionDefaults();
115114
if (indexOptionDefaults.getStorageEngine() != null) {

driver/src/main/com/mongodb/DB.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ public DBCollection createView(final String viewName, final String viewOn, final
347347
}
348348

349349

350+
@SuppressWarnings("deprecation")
350351
private CreateCollectionOperation getCreateCollectionOperation(final String collectionName, final DBObject options) {
351352
if (options.get("size") != null && !(options.get("size") instanceof Number)) {
352353
throw new IllegalArgumentException("'size' should be Number");

driver/src/main/com/mongodb/MongoDatabaseImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public void createCollection(final String collectionName) {
168168
}
169169

170170
@Override
171+
@SuppressWarnings("deprecation")
171172
public void createCollection(final String collectionName, final CreateCollectionOptions createCollectionOptions) {
172173
CreateCollectionOperation operation = new CreateCollectionOperation(name, collectionName, writeConcern)
173174
.collation(createCollectionOptions.getCollation())

0 commit comments

Comments
 (0)