Skip to content

Commit 6f2aa50

Browse files
ramasai1jyemin
andauthored
Deprecate WriteConcernError errorLabels property(#840)
JAVA-4421 Co-authored-by: Jeff Yemin <[email protected]>
1 parent 30eb794 commit 6f2aa50

File tree

6 files changed

+13
-0
lines changed

6 files changed

+13
-0
lines changed

driver-core/src/main/com/mongodb/MongoBulkWriteException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public MongoBulkWriteException(final BulkWriteResult writeResult, final List<Bul
6767
* @param errorLabels any server errorLabels
6868
* @since 4.1
6969
*/
70+
@SuppressWarnings("deprecation")
7071
public MongoBulkWriteException(final BulkWriteResult writeResult, final List<BulkWriteError> writeErrors,
7172
@Nullable final WriteConcernError writeConcernError, final ServerAddress serverAddress,
7273
final Set<String> errorLabels) {

driver-core/src/main/com/mongodb/MongoWriteConcernException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public MongoWriteConcernException(final WriteConcernError writeConcernError, fin
5353
* @param serverAddress the non-null server address
5454
* @since 3.2
5555
*/
56+
@SuppressWarnings("deprecation")
5657
public MongoWriteConcernException(final WriteConcernError writeConcernError, @Nullable final WriteConcernResult writeConcernResult,
5758
final ServerAddress serverAddress) {
5859
super(writeConcernError.getCode(), writeConcernError.getMessage(), serverAddress);
@@ -64,6 +65,7 @@ public MongoWriteConcernException(final WriteConcernError writeConcernError, @Nu
6465
}
6566

6667
@Override
68+
@SuppressWarnings("deprecation")
6769
public void addLabel(final String errorLabel) {
6870
writeConcernError.addLabel(errorLabel);
6971
super.addLabel(errorLabel);

driver-core/src/main/com/mongodb/bulk/WriteConcernError.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public WriteConcernError(final int code, final String codeName, final String mes
5959
* @param details any details
6060
* @param errorLabels any error labels
6161
* @since 4.1
62+
* @deprecated Prefer using error labels included in the top level response document
6263
*/
64+
@Deprecated
6365
public WriteConcernError(final int code, final String codeName, final String message, final BsonDocument details,
6466
final Set<String> errorLabels) {
6567
this.code = code;
@@ -113,7 +115,9 @@ public BsonDocument getDetails() {
113115
* @param errorLabel the non-null error label to add to the exception
114116
*
115117
* @since 4.1
118+
* @deprecated Prefer using error labels included in the top level response document
116119
*/
120+
@Deprecated
117121
public void addLabel(final String errorLabel) {
118122
notNull("errorLabel", errorLabel);
119123
errorLabels.add(errorLabel);
@@ -124,8 +128,10 @@ public void addLabel(final String errorLabel) {
124128
*
125129
* @return the error labels, which may not be null but may be empty
126130
* @since 4.1
131+
* @deprecated Prefer using error labels included in the top level response document
127132
*/
128133
@NonNull
134+
@Deprecated
129135
public Set<String> getErrorLabels() {
130136
return Collections.unmodifiableSet(errorLabels);
131137
}

driver-core/src/main/com/mongodb/internal/connection/BulkWriteBatchCombiner.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public MongoBulkWriteException getError() {
168168
serverAddress, errorLabels);
169169
}
170170

171+
@SuppressWarnings("deprecation")
171172
private void mergeWriteConcernError(final WriteConcernError writeConcernError) {
172173
if (writeConcernError != null) {
173174
if (writeConcernErrors.isEmpty()) {

driver-core/src/main/com/mongodb/internal/operation/FindAndModifyHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public T apply(final BsonDocument result, final AsyncConnection connection) {
5353
};
5454
}
5555

56+
@SuppressWarnings("deprecation")
5657
private static <T> T transformDocument(final BsonDocument result, final ServerAddress serverAddress) {
5758
if (hasWriteConcernError(result)) {
5859
MongoWriteConcernException writeConcernException = new MongoWriteConcernException(

driver-core/src/main/com/mongodb/internal/operation/WriteConcernHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public static boolean hasWriteConcernError(final BsonDocument result) {
6060
return result.containsKey("writeConcernError");
6161
}
6262

63+
@SuppressWarnings("deprecation")
6364
public static MongoWriteConcernException createWriteConcernException(final BsonDocument result, final ServerAddress serverAddress) {
6465
MongoWriteConcernException writeConcernException = new MongoWriteConcernException(
6566
createWriteConcernError(result.getDocument("writeConcernError")),
@@ -69,6 +70,7 @@ public static MongoWriteConcernException createWriteConcernException(final BsonD
6970
return writeConcernException;
7071
}
7172

73+
@SuppressWarnings("deprecation")
7274
public static WriteConcernError createWriteConcernError(final BsonDocument writeConcernErrorDocument) {
7375
return new WriteConcernError(writeConcernErrorDocument.getNumber("code").intValue(),
7476
writeConcernErrorDocument.getString("codeName", new BsonString("")).getValue(),

0 commit comments

Comments
 (0)