-
Bug
-
Resolution: Fixed
-
P4
-
1.1.4, 1.1.5
-
merlin
-
generic, x86, sparc
-
generic, solaris_2.5, windows_95
Name: yyC67448 Date: 02/19/98
The java.net.URLConnection.setDoOutput(boolean dooutput) does not alter the
doInput value. So when doOutput is explicitly set to true the default value
for doInput remain true.
Here is the javadoc comment for method setDoInput
/**
* Sets the value of the <code>doInput</code> field for this
* <code>URLConnection</code> to the specified value.
* <p>
* A URL connection can be used for input and/or output. Set the DoInput
* flag to true if you intend to use the URL connection for input,
* false if not. The default is true unless DoOutput is explicitly
* set to true, in which case DoInput defaults to false.
*
* @param value the new value.
* @see java.net.URLConnection#doInput
* @since JDK1.0
*/
Here is the test demonstrating the bug:
------------------------ Test.java ---------------------------------------
import java.net.*;
public class Test
{
public static void main(String args[])
{
URL url = null;
URLConnection conn = null;
String spec="http://web2.javasoft.com/index.html";
try {
url = new URL(spec);
conn = url.openConnection();
} catch(Exception e)
{
System.out.println("Failed. Unexpected exception:" + e);
System.exit(-1);
}
/*
* Setting doOutput value to true
*/
conn.setDoOutput(true);
/*
* Verify, that doOutput is really true
*/
if( conn.getDoOutput() != true )
{
System.out.println("Failed. doOutput isn't set to true");
System.exit(-1);
}
/*
* Now verify the doInput value
*/
if( conn.getDoInput() != false )
{
System.out.println("Failed. doInput is true.");
System.exit(-1);
}
System.out.println("Passed. OKAY");
}
}
------------------------- Output from the test ----------------------------
Failed. doInput is true.
---------------------------------------------------------------------------
======================================================================