Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4976917
Votes 0
Synopsis Client blocks on getInputStream even after server completes its response
Category java:classes_net
Reported Against 1.3.1
Release Fixed 1.3.1_12
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 12-JAN-2004
Description



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.

======================================================================
Work Around
N/A
Evaluation
In 1.4.0 the handling of chunked responses was re-implemented - see 4333920.
For older 1.3.x installations it may be possible to workaround the issue by
preventing the server from returning a chunked response. See 4333920 for 
an example of how this is done with Apache.
 xxxxx@xxxxx  2004-01-12
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang