dmfs / oauth2-essentials

An OAuth2 client implementation based on http-client-essentials.
Apache License 2.0
86 stars 21 forks source link

java.lang.ArrayStoreException: org.dmfs.oauth2.client.http.requests.parameters.OptionalScopeParam #99

Closed SButterfly closed 1 year ago

SButterfly commented 1 year ago

Starting from 0.20.0 accessToken throws exception

                    var clientCredentialsGrant = new ClientCredentialsGrant(this.oAuth2Client, new BasicScope("scope"));
                    return clientCredentialsGrant.accessToken(executor);

Part of stacktrace

java.lang.ArrayStoreException: org.dmfs.oauth2.client.http.requests.parameters.OptionalScopeParam
    at org.dmfs.oauth2.client.http.requests.ClientCredentialsTokenRequest.<init>(ClientCredentialsTokenRequest.java:56) ~[oauth2-essentials-0.22.0.jar:?]
    at org.dmfs.oauth2.client.grants.ClientCredentialsGrant.accessToken(ClientCredentialsGrant.java:60) ~[oauth2-essentials-0.22.0.jar:?]

My suspicious about this code:

new PresentValues<>(
                        new OptionalScopeParam(scope))

https://github.com/dmfs/oauth2-essentials/blob/bdd17f1762f7f130a327170ffd5ee22d662e67dc/src/main/java/org/dmfs/oauth2/client/http/requests/ClientCredentialsTokenRequest.java#L61

dmfs commented 1 year ago

thx for the report. I'll look into that

dmfs commented 1 year ago

The strange part is, there is a unit test for ClientCredentialsTokenRequest: https://github.com/dmfs/oauth2-essentials/blob/main/src/test/java/org/dmfs/oauth2/client/http/requests/ClientCredentialsTokenRequestTest.java#L52

Which Java version do you use?

dmfs commented 1 year ago

I've published the SNAPSHOT version 0.22.1-alpha-99-remove-some-jems-classes-in-favour-of-jems2.2.20230905T170543Z-SNAPSHOT of PR #102 on oss.sonatype.org. Can you check if that fixes the issue for you?

dmfs commented 1 year ago

Also, can you try to run the test suite of this project on your machine?

SButterfly commented 1 year ago

I've published the SNAPSHOT version 0.22.1-alpha-99-remove-some-jems-classes-in-favour-of-jems2.2.20230905T170543Z-SNAPSHOT of PR https://github.com/dmfs/oauth2-essentials/pull/102 on oss.sonatype.org. Can you check if that fixes the issue for you?

Yes. it helped

Which Java version do you use?

openjdk 11.0.20 2023-07-18 OpenJDK Runtime Environment Homebrew (build 11.0.20+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.20+0, mixed mode)

Also, can you try to run the test suite of this project on your machine?

Ran on the main branch. Zero failed tests. Very strange.

dmfs commented 1 year ago

thx. I'll merge and publish the changes after I checked if any other Grant type might be affected.

dmfs commented 1 year ago

fixed in 0.22.1 , thx for reporting