Index: src/test/java/tests/api/java/net/URLConnectionTest.java =================================================================== --- src/test/java/tests/api/java/net/URLConnectionTest.java (revision 488549) +++ src/test/java/tests/api/java/net/URLConnectionTest.java (working copy) @@ -940,17 +940,39 @@ } /** + * @throws IOException + * @throws MalformedURLException * @tests java.net.URLConnection#setDoInput(boolean) */ - public void test_setDoInputZ() { + public void test_setDoInputZ() throws MalformedURLException, IOException { assertTrue("Used to test", true); + HttpURLConnection u = null; + + u = (HttpURLConnection) (new URL("http://intel.com").openConnection()); + u.connect(); + + try { + u.setDoInput(true); + } catch (IllegalStateException e) { // expected + } } /** + * @throws IOException + * @throws MalformedURLException * @tests java.net.URLConnection#setDoOutput(boolean) */ - public void test_setDoOutputZ() { + public void test_setDoOutputZ() throws MalformedURLException, IOException { assertTrue("Used to test", true); + HttpURLConnection u = null; + + u = (HttpURLConnection) (new URL("http://intel.com").openConnection()); + u.connect(); + + try { + u.setDoOutput(true); + } catch (IllegalStateException e) { // expected + } } /** Index: src/main/java/java/net/URLConnection.java =================================================================== --- src/main/java/java/net/URLConnection.java (revision 488549) +++ src/main/java/java/net/URLConnection.java (working copy) @@ -870,7 +870,7 @@ */ public void setDoInput(boolean newValue) { if (connected) { - throw new IllegalAccessError(Msg.getString("K0037")); + throw new IllegalStateException(Msg.getString("K0037")); } this.doInput = newValue; } @@ -893,7 +893,7 @@ */ public void setDoOutput(boolean newValue) { if (connected) { - throw new IllegalAccessError(Msg.getString("K0037")); + throw new IllegalStateException(Msg.getString("K0037")); } this.doOutput = newValue; }