8028562: Test SSLSocketSSLEngineTemplate.java intermittent failed with "Data length error"

Test stabilization, read one more time in case of message fragment

Reviewed-by: mullan, xuelei
This commit is contained in:
Zaiyao Liu 2013-12-15 20:24:45 -08:00 committed by Xue-Lei Andrew Fan
parent 00b823a27a
commit 7c18844372

View File

@ -221,6 +221,9 @@ public class SSLSocketSSLEngineTemplate {
try {
boolean closed = false;
// will try to read one more time in case client message
// is fragmented to multiple pieces
boolean retry = true;
InputStream is = socket.getInputStream();
OutputStream os = socket.getOutputStream();
@ -295,8 +298,14 @@ public class SSLSocketSSLEngineTemplate {
/*
* A sanity check to ensure we got what was sent.
*/
if (serverIn.remaining() != clientMsg.length) {
throw new Exception("Client: Data length error");
if (serverIn.remaining() != clientMsg.length) {
if (retry && serverIn.remaining() < clientMsg.length) {
log("Need to read more from client");
retry = false;
continue;
} else {
throw new Exception("Client: Data length error");
}
}
for (int i = 0; i < clientMsg.length; i++) {