Fix the build timeout when 'leak' profile is active
Motivation: AbstractByteBufTest.testInternalBuffer() uses writeByte() operations to populate the sample data. Usually, this isn't a problem, but it starts to take a lot of time when the resource leak detection level gets higher. In our CI machine, testInternalBuffer() takes more than 30 minutes, causing the build timeout when the 'leak' profile is active (paranoid level resource detection.) Modification: Populate the sample data using ThreadLocalRandom.nextBytes() instead of using millions of writeByte() operations. Result: Test runs much faster when leak detection level is high.
This commit is contained in:
parent
0a8ff3b52d
commit
3d8d843198
@ -17,6 +17,7 @@ package io.netty.buffer;
|
||||
|
||||
import io.netty.util.CharsetUtil;
|
||||
import io.netty.util.IllegalReferenceCountException;
|
||||
import io.netty.util.internal.ThreadLocalRandom;
|
||||
import org.junit.After;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
@ -1742,15 +1743,15 @@ public abstract class AbstractByteBufTest {
|
||||
ByteBuffer buf = buffer.internalNioBuffer(0, 1);
|
||||
assertEquals(1, buf.remaining());
|
||||
|
||||
for (int i = 0; i < a; i++) {
|
||||
buffer.writeByte(i);
|
||||
}
|
||||
byte[] data = new byte[a];
|
||||
ThreadLocalRandom.current().nextBytes(data);
|
||||
buffer.writeBytes(data);
|
||||
|
||||
buf = buffer.internalNioBuffer(0, a);
|
||||
assertEquals(a, buf.remaining());
|
||||
|
||||
for (int i = 0; i < a; i++) {
|
||||
assertEquals((byte) i, buf.get());
|
||||
assertEquals(data[i], buf.get());
|
||||
}
|
||||
assertFalse(buf.hasRemaining());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user