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
43bfc244cf
commit
71737a2a65
@ -17,6 +17,7 @@ package io.netty.buffer;
|
|||||||
|
|
||||||
import io.netty.util.CharsetUtil;
|
import io.netty.util.CharsetUtil;
|
||||||
import io.netty.util.IllegalReferenceCountException;
|
import io.netty.util.IllegalReferenceCountException;
|
||||||
|
import io.netty.util.internal.ThreadLocalRandom;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assume;
|
import org.junit.Assume;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -1742,15 +1743,15 @@ public abstract class AbstractByteBufTest {
|
|||||||
ByteBuffer buf = buffer.internalNioBuffer(0, 1);
|
ByteBuffer buf = buffer.internalNioBuffer(0, 1);
|
||||||
assertEquals(1, buf.remaining());
|
assertEquals(1, buf.remaining());
|
||||||
|
|
||||||
for (int i = 0; i < a; i++) {
|
byte[] data = new byte[a];
|
||||||
buffer.writeByte(i);
|
ThreadLocalRandom.current().nextBytes(data);
|
||||||
}
|
buffer.writeBytes(data);
|
||||||
|
|
||||||
buf = buffer.internalNioBuffer(0, a);
|
buf = buffer.internalNioBuffer(0, a);
|
||||||
assertEquals(a, buf.remaining());
|
assertEquals(a, buf.remaining());
|
||||||
|
|
||||||
for (int i = 0; i < a; i++) {
|
for (int i = 0; i < a; i++) {
|
||||||
assertEquals((byte) i, buf.get());
|
assertEquals(data[i], buf.get());
|
||||||
}
|
}
|
||||||
assertFalse(buf.hasRemaining());
|
assertFalse(buf.hasRemaining());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user