@@ -56,7 +56,7 @@ public class ResizeRequest extends AcknowledgedRequest<ResizeRequest> implements
56
56
private CreateIndexRequest targetIndexRequest ;
57
57
private String sourceIndex ;
58
58
private ResizeType type = ResizeType .SHRINK ;
59
- private boolean copySettings = false ;
59
+ private Boolean copySettings ;
60
60
61
61
ResizeRequest () {}
62
62
@@ -80,6 +80,7 @@ public ActionRequestValidationException validate() {
80
80
if (type == ResizeType .SPLIT && IndexMetaData .INDEX_NUMBER_OF_SHARDS_SETTING .exists (targetIndexRequest .settings ()) == false ) {
81
81
validationException = addValidationError ("index.number_of_shards is required for split operations" , validationException );
82
82
}
83
+ assert copySettings == null || copySettings ;
83
84
return validationException ;
84
85
}
85
86
@@ -98,10 +99,10 @@ public void readFrom(StreamInput in) throws IOException {
98
99
} else {
99
100
type = ResizeType .SHRINK ; // BWC this used to be shrink only
100
101
}
101
- if (in .getVersion ().onOrAfter (Version .V_6_4_0 )) {
102
- copySettings = in . readBoolean () ;
102
+ if (in .getVersion ().before (Version .V_6_4_0 )) {
103
+ copySettings = null ;
103
104
} else {
104
- copySettings = false ;
105
+ copySettings = in . readOptionalBoolean () ;
105
106
}
106
107
}
107
108
@@ -113,8 +114,11 @@ public void writeTo(StreamOutput out) throws IOException {
113
114
if (out .getVersion ().onOrAfter (ResizeAction .COMPATIBILITY_VERSION )) {
114
115
out .writeEnum (type );
115
116
}
116
- if (out .getVersion ().onOrAfter (Version .V_6_4_0 )) {
117
- out .writeBoolean (copySettings );
117
+ // noinspection StatementWithEmptyBody
118
+ if (out .getVersion ().before (Version .V_6_4_0 )) {
119
+
120
+ } else {
121
+ out .writeOptionalBoolean (copySettings );
118
122
}
119
123
}
120
124
@@ -187,11 +191,14 @@ public ResizeType getResizeType() {
187
191
return type ;
188
192
}
189
193
190
- public void setCopySettings (final boolean copySettings ) {
194
+ public void setCopySettings (final Boolean copySettings ) {
195
+ if (copySettings != null && copySettings == false ) {
196
+ throw new IllegalArgumentException ("[copySettings] can not be explicitly set to [false]" );
197
+ }
191
198
this .copySettings = copySettings ;
192
199
}
193
200
194
- public boolean getCopySettings () {
201
+ public Boolean getCopySettings () {
195
202
return copySettings ;
196
203
}
197
204
0 commit comments