FULL PRODUCT VERSION :
ADDITIONAL OS VERSION INFORMATION :
All OS
A DESCRIPTION OF THE PROBLEM :
DataOutputSteam function writeInt() should create a 4 byte packet but instead creates 2 packets. 1 is a 1 byte packet and then it is followed by a 3 byte packet.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use wireshark to monitor packets being sent by server to client through writeInt(). Compare with writeLong().
Source code attached is two separate programs, one for server and one for client.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
//Server source code
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;
import java.io.DataOutputStream;
public class TestServer {
/**
* Runs the server.
*/
public static void main(String[] args) throws Exception {
ServerSocket listener = new ServerSocket(11000);
int len = 13421772;
long lon = 500000000;
try {
while (true) {
Socket socket = listener.accept();
try {
DataOutputStream dataOut = new DataOutputStream(socket.getOutputStream());
dataOut.writeInt(len);
dataOut.flush();
} finally {
socket.close();
}
}
}
finally {
listener.close();
}
}
}
===================================
//Client source code
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
public class TestClient {
public static void main(String[] args) throws IOException {
String serverAddress = "9.41.222.238";
Socket s = new Socket(serverAddress, 11000);
BufferedReader getResponse =
new BufferedReader(new InputStreamReader(s.getInputStream()));
String answer = getResponse.readLine();
System.out.println("answer= " + answer);
System.exit(0);
}
}
---------- END SOURCE ----------
ADDITIONAL OS VERSION INFORMATION :
All OS
A DESCRIPTION OF THE PROBLEM :
DataOutputSteam function writeInt() should create a 4 byte packet but instead creates 2 packets. 1 is a 1 byte packet and then it is followed by a 3 byte packet.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use wireshark to monitor packets being sent by server to client through writeInt(). Compare with writeLong().
Source code attached is two separate programs, one for server and one for client.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
//Server source code
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;
import java.io.DataOutputStream;
public class TestServer {
/**
* Runs the server.
*/
public static void main(String[] args) throws Exception {
ServerSocket listener = new ServerSocket(11000);
int len = 13421772;
long lon = 500000000;
try {
while (true) {
Socket socket = listener.accept();
try {
DataOutputStream dataOut = new DataOutputStream(socket.getOutputStream());
dataOut.writeInt(len);
dataOut.flush();
} finally {
socket.close();
}
}
}
finally {
listener.close();
}
}
}
===================================
//Client source code
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
public class TestClient {
public static void main(String[] args) throws IOException {
String serverAddress = "9.41.222.238";
Socket s = new Socket(serverAddress, 11000);
BufferedReader getResponse =
new BufferedReader(new InputStreamReader(s.getInputStream()));
String answer = getResponse.readLine();
System.out.println("answer= " + answer);
System.exit(0);
}
}
---------- END SOURCE ----------
- csr for
-
JDK-8311882 DataOuputStream should clarify that it might write primitive types as multiple byte groups
- Closed
- relates to
-
JDK-8254078 DataOutputStream is very slow post-disabling of Biased Locking
- Resolved