Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8259628: jdk/net/ExtendedSocketOption/AsynchronousSocketChannelNAPITest.java fails intermittently #2162

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -107,19 +107,29 @@ public void testSocketChannel() throws Exception {
assertEquals((int) s.getOption(SO_INCOMING_NAPI_ID), 0);

for (int i = 0; i < 10; i++) {
s.write(ByteBuffer.wrap("test".getBytes()));
String testStr = "test_" + i;
var writeBuf = ByteBuffer.wrap(testStr.getBytes());
s.write(writeBuf);

socketID = s.getOption(SO_INCOMING_NAPI_ID);
assertEquals(socketID, 0, "AsynchronousSocketChannel: Sender");

c.read(ByteBuffer.allocate(128));
var readBuf = ByteBuffer.allocate(128);
int readData = c.read(readBuf).get();
clientID = ss.getOption(SO_INCOMING_NAPI_ID);

// compare buffers
readBuf.flip();
writeBuf.flip();
assertEquals(readData, writeBuf.remaining());
assertEquals(writeBuf.mismatch(readBuf), -1);

// check ID remains consistent
if (initialRun) {
assertTrue(clientID >= 0, "AsynchronousSocketChannel: Receiver");
initialRun = false;
} else {
assertEquals(clientID, tempID);
initialRun = false;
}
tempID = clientID;
}
Expand Down