Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,12 @@ public Info(String name, ThreadPoolType type, int min, int max, @Nullable TimeVa

public Info(StreamInput in) throws IOException {
name = in.readString();
type = ThreadPoolType.fromType(in.readString());
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();
keepAlive = in.readOptionalTimeValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ private static NodeInfo createNodeInfo() {
List<ThreadPool.Info> threadPoolInfos = new ArrayList<>(numThreadPools);
for (int i = 0; i < numThreadPools; i++) {
threadPoolInfos.add(
new ThreadPool.Info(randomAlphaOfLengthBetween(3, 10), randomFrom(ThreadPool.ThreadPoolType.values()), randomInt())
new ThreadPool.Info(
randomAlphaOfLengthBetween(3, 10),
randomFrom(ThreadPool.ThreadPoolType.FIXED, ThreadPool.ThreadPoolType.SCALING),
randomInt()
)
);
}
threadPoolInfo = new ThreadPoolInfo(threadPoolInfos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class ThreadPoolSerializationTests extends ESTestCase {
@Before
public void setUp() throws Exception {
super.setUp();
threadPoolType = randomFrom(ThreadPool.ThreadPoolType.values());
threadPoolType = randomFrom(ThreadPool.ThreadPoolType.FIXED, ThreadPool.ThreadPoolType.SCALING);
}

public void testThatQueueSizeSerializationWorks() throws Exception {
Expand Down 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));
}
}