Skip to content

Commit

Permalink
Address review comment and add additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-ivanov-es committed Dec 13, 2024
1 parent 7abd18e commit 84f950c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -941,12 +941,11 @@ public Info(String name, ThreadPoolType type, int min, int max, @Nullable TimeVa

public Info(StreamInput in) throws IOException {
name = in.readString();
String typeAsString = in.readString();
if ("fixed_auto_queue_size".equals(typeAsString) || "direct".equals(typeAsString)) {
type = ThreadPoolType.FIXED;
} else {
type = ThreadPoolType.fromType(typeAsString);
}
ThreadPoolType receivedType = ThreadPoolType.fromType(in.readString());
type = switch (receivedType) {
case DIRECT, FIXED_AUTO_QUEUE_SIZE -> ThreadPoolType.FIXED;
default -> receivedType;
};

min = in.readInt();
max = in.readInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,15 @@ public void testThatThreadPoolTypeIsSerializedCorrectly() throws IOException {

assertThat(newInfo.getThreadPoolType(), is(threadPoolType));
}

public void testThatDeprecatedTypesDeserializedAsFixed() throws IOException {
ThreadPool.Info info = new ThreadPool.Info("foo", ThreadPool.ThreadPoolType.DIRECT);
output.setTransportVersion(TransportVersion.current());
info.writeTo(output);

StreamInput input = output.bytes().streamInput();
ThreadPool.Info newInfo = new ThreadPool.Info(input);

assertThat(newInfo.getThreadPoolType(), is(ThreadPool.ThreadPoolType.FIXED));
}
}

0 comments on commit 84f950c

Please sign in to comment.