RFR: 8252767: URLConnection.setRequestProperty throws IllegalAccessError [v5]

Chris Hegarty chegar at openjdk.java.net
Mon Sep 7 11:27:05 UTC 2020


On Mon, 7 Sep 2020 11:04:35 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Can I please get a review and a sponsor for a fix for the issue reported at
>> https://bugs.openjdk.java.net/browse/JDK-8252767?
>> As noted in that issue, the `sun.net.www.URLConnection#setRequestProperty` is throwing a `IllegalAccessError` instead
>> of a `IllegalStateException`. The commit here fixes that and includes a test which reproduces the issue and verifies
>> the fix.  Would a CSR be needed for this change?
>
> Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Convert to TestNG test case

test/jdk/java/net/URLConnection/RequestProperties.java line 90:

> 88:         try {
> 89:             conn.addRequestProperty(null, "hello");
> 90:             Assert.fail("addRequestProperty on " + conn.getClass().getName()

Now that the test is using TestNG, you can use the convenient Assert.assertThrows / Assert.expectThrows, e.g. something
like:

static final Class<NullPointerException> NPE = NullPointerException.class;

assertThrows(NPE, () -> conn.addRequestProperty(null, "hello"));

similar for IllegalStateException

-------------

PR: https://git.openjdk.java.net/jdk/pull/26


More information about the net-dev mailing list