Name: dk106046 Date: 01/12/2004
The Customer has implemented the following code (pasted below) in his client application. After the line outputstream.close();, The system waits for some time and then executes the next line.This behaviour is seen in 1.3.1 only. The same problem seems to be fixed in 1.4.1.
Code Snippet:
// Write the Data Container to the server.
outputstream.writeObject(dc);
outputstream.flush();
outputstream.close();
// This code should execute after the servlet closes the output stream.
// We should not have to wait for the servlet to finish the doWork() //method.
ObjectInputStream input =
new ObjectInputStream(urlConnection.getInputStream());
DataContainer resultData = (DataContainer) input.readObject();
Explanation:
Client blocks on getInputStream even after server completes its response.
Following Scenario will explain the problem clearly:
Client:
1. sends the data (request) ,outputstream.writeObject(dc); (LockingClient.java,line # 68)
2. Server responds to this as below:
output.writeObject(result);
output.flush();
output.close(); //( Lockingservlet.java, Line# 92)
3.Now server does some other work which is simulated in the testcase as,
doWait() ,where server waits for 10 secs.
4. Once the above 2nd step is over, client is expected to come out of
Server and execute the following in the Client:
ObjectInputStream input = new
ObjectInputStream(urlConnection.getInputStream());
//(LockingClient.java,Line #75)
In 1.3.1 JDK, Once the step 2 is over, it comes to step 4 but while executing the "getInputStream", it blocks on "readLine" in ChunkInputStream, until the step 3 is over.
In 1.4.1 JDK, once the step 2 is over, it starts executing the step 4 and it does not wait for the step 3 to execute/complete.
The application source code is available on request.
======================================================================