Skip to content

Commit

Permalink
BWC compatibility fix for crypto settings in put repository request
Browse files Browse the repository at this point in the history
Signed-off-by: Vikas Bansal <43470111+vikasvb90@users.noreply.github.com>
  • Loading branch information
vikasvb90 committed Sep 5, 2023
1 parent 63ce832 commit 37f5caa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.opensearch.OpenSearchException.OpenSearchExceptionHandle;
import static org.opensearch.OpenSearchException.OpenSearchExceptionHandleRegistry.registerExceptionHandle;
import static org.opensearch.OpenSearchException.UNKNOWN_VERSION_ADDED;
import static org.opensearch.Version.V_2_10_0;
import static org.opensearch.Version.V_2_1_0;
import static org.opensearch.Version.V_2_4_0;
import static org.opensearch.Version.V_2_5_0;
Expand Down Expand Up @@ -1173,7 +1174,7 @@ public static void registerExceptions() {
V_2_7_0
)
);
registerExceptionHandle(new OpenSearchExceptionHandle(CryptoRegistryException.class, CryptoRegistryException::new, 171, V_3_0_0));
registerExceptionHandle(new OpenSearchExceptionHandle(CryptoRegistryException.class, CryptoRegistryException::new, 171, V_2_10_0));
registerExceptionHandle(
new OpenSearchExceptionHandle(
org.opensearch.cluster.block.IndexCreateBlockException.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public PutRepositoryRequest(StreamInput in) throws IOException {
settings = readSettingsFromStream(in);
verify = in.readBoolean();

if (in.getVersion().onOrAfter(Version.V_3_0_0)) {
if (in.getVersion().onOrAfter(Version.V_2_10_0)) {
cryptoSettings = in.readOptionalWriteable(CryptoSettings::new);
}
}
Expand Down Expand Up @@ -275,7 +275,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeString(type);
writeSettingsToStream(settings, out);
out.writeBoolean(verify);
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
if (out.getVersion().onOrAfter(Version.V_2_10_0)) {
out.writeOptionalWriteable(cryptoSettings);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public RepositoryMetadata(StreamInput in) throws IOException {
settings = Settings.readSettingsFromStream(in);
generation = in.readLong();
pendingGeneration = in.readLong();
if (in.getVersion().onOrAfter(Version.V_3_0_0)) {
if (in.getVersion().onOrAfter(Version.V_2_10_0)) {
cryptoMetadata = in.readOptionalWriteable(CryptoMetadata::new);
} else {
cryptoMetadata = null;
Expand All @@ -192,7 +192,7 @@ public void writeTo(StreamOutput out) throws IOException {
Settings.writeSettingsToStream(settings, out);
out.writeLong(generation);
out.writeLong(pendingGeneration);
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
if (out.getVersion().onOrAfter(Version.V_2_10_0)) {
out.writeOptionalWriteable(cryptoMetadata);
}
}
Expand Down

0 comments on commit 37f5caa

Please sign in to comment.