Add cast to help compiler to build (#11587)

Motivation:

Sometimes intellij fails to build because the compiler cant really figure out what to do. We can workaround this by adding some explicit casts.

Modifications:

Add explicits casts

Result:

No more problems with intellij
This commit is contained in:
Norman Maurer 2021-08-18 09:21:19 +02:00
parent 22e71e4efd
commit 8549d7dc87
5 changed files with 20 additions and 19 deletions

View File

@ -63,7 +63,7 @@ public class ByteToMessageCodecTest {
assertTrue(ch.writeInbound(buffer));
ch.pipeline().remove(codec);
assertTrue(ch.finish());
assertEquals(1, (int) ch.readInbound());
assertEquals(1, (Integer) ch.readInbound());
ByteBuf buf = ch.readInbound();
assertEquals(Unpooled.wrappedBuffer(new byte[]{'0'}), buf);

View File

@ -500,10 +500,10 @@ public class ByteToMessageDecoderTest {
};
EmbeddedChannel channel = new EmbeddedChannel(decoder);
assertTrue(channel.writeInbound(Unpooled.wrappedBuffer(new byte[]{1, 2, 3, 4, 5})));
assertEquals((byte) 1, (byte) channel.readInbound());
assertEquals((byte) 2, (byte) channel.readInbound());
assertEquals((byte) 3, (byte) channel.readInbound());
assertEquals((byte) 4, (byte) channel.readInbound());
assertEquals((byte) 1, (Byte) channel.readInbound());
assertEquals((byte) 2, (Byte) channel.readInbound());
assertEquals((byte) 3, (Byte) channel.readInbound());
assertEquals((byte) 4, (Byte) channel.readInbound());
ByteBuf buffer5 = channel.readInbound();
assertEquals((byte) 5, buffer5.readByte());
assertFalse(buffer5.isReadable());

View File

@ -92,8 +92,8 @@ public class FlushConsolidationHandlerTest {
channel.flush();
channel.runPendingTasks();
assertEquals(3, flushCount.get());
assertEquals(1L, (long) channel.readOutbound());
assertEquals(2L, (long) channel.readOutbound());
assertEquals(1L, (Long) channel.readOutbound());
assertEquals(2L, (Long) channel.readOutbound());
assertNull(channel.readOutbound());
assertFalse(channel.finish());
}
@ -108,7 +108,7 @@ public class FlushConsolidationHandlerTest {
assertNull(channel.readOutbound());
channel.close();
assertEquals(1, flushCount.get());
assertEquals(1L, (long) channel.readOutbound());
assertEquals(1L, (Long) channel.readOutbound());
assertNull(channel.readOutbound());
assertFalse(channel.finish());
}
@ -123,7 +123,7 @@ public class FlushConsolidationHandlerTest {
assertNull(channel.readOutbound());
channel.disconnect();
assertEquals(1, flushCount.get());
assertEquals(1L, (long) channel.readOutbound());
assertEquals(1L, (Long) channel.readOutbound());
assertNull(channel.readOutbound());
assertFalse(channel.finish());
}
@ -138,7 +138,7 @@ public class FlushConsolidationHandlerTest {
assertNull(channel.readOutbound());
channel.pipeline().fireExceptionCaught(new IllegalStateException());
assertEquals(1, flushCount.get());
assertEquals(1L, (long) channel.readOutbound());
assertEquals(1L, (Long) channel.readOutbound());
assertNull(channel.readOutbound());
assertThrows(IllegalStateException.class, new Executable() {
@Override
@ -158,7 +158,7 @@ public class FlushConsolidationHandlerTest {
assertNull(channel.readOutbound());
channel.pipeline().remove(FlushConsolidationHandler.class);
assertEquals(1, flushCount.get());
assertEquals(1L, (long) channel.readOutbound());
assertEquals(1L, (Long) channel.readOutbound());
assertNull(channel.readOutbound());
assertFalse(channel.finish());
}
@ -172,8 +172,8 @@ public class FlushConsolidationHandlerTest {
final EmbeddedChannel channel = newChannel(flushCount, true);
channel.writeAndFlush(1L).addListener(future -> channel.writeAndFlush(1L));
channel.flushOutbound();
assertEquals(1L, ((Long) channel.readOutbound()).longValue());
assertEquals(1L, ((Long) channel.readOutbound()).longValue());
assertEquals(1L, (Long) channel.readOutbound());
assertEquals(1L, (Long) channel.readOutbound());
assertNull(channel.readOutbound());
assertFalse(channel.finish());
}

View File

@ -268,7 +268,7 @@ public class ChunkedWriteHandlerTest {
ch.writeAndFlush(input).syncUninterruptibly();
assertTrue(ch.finish());
assertEquals(0, (int) ch.readOutbound());
assertEquals(0, (Integer) ch.readOutbound());
assertNull(ch.readOutbound());
}

View File

@ -262,9 +262,10 @@ public class PendingWriteQueueTest {
assertTrue(promise3.isSuccess());
channel.runPendingTasks();
assertTrue(channel.finish());
assertEquals(1L, (long) channel.readOutbound());
assertEquals(2L, (long) channel.readOutbound());
assertEquals(3L, (long) channel.readOutbound());
assertEquals(1L, (Long) channel.readOutbound());
assertEquals(2L, (Long) channel.readOutbound());
assertEquals(3L, (Long) channel.readOutbound());
}
@Disabled("Need to verify and think about if the assumptions made by this test are valid at all.")
@ -322,8 +323,8 @@ public class PendingWriteQueueTest {
assertTrue(promise2.isSuccess());
assertTrue(channel.finish());
assertEquals(1L, (long) channel.readOutbound());
assertEquals(2L, (long) channel.readOutbound());
assertEquals(1L, (Long) channel.readOutbound());
assertEquals(2L, (Long) channel.readOutbound());
assertNull(channel.readOutbound());
assertNull(channel.readInbound());
}