OAuth2Options inexplicably fails with immutable Map passed into extraParameters
alefarendsen opened this issue · 3 comments
Setting the extra parameters on OAuth2Options fails if the extra parameters I set are contained within an immutable map (within the JsonObject).
val extraParams = JsonObject(mapOf("client_id" to CONSTANTS.CLIENT_ID))
In replaceVariables
the replacements are done on the map passed previously. This is understandable when looking at the implementation, but it'll obviously fail if this is an immutable map and it does so without a clear exception.
Currently, it fails with the following exception:
java.lang.UnsupportedOperationException
at java.base/java.util.AbstractMap$SimpleImmutableEntry.setValue(AbstractMap.java:815)
at io.vertx.ext.auth.oauth2.OAuth2Options.replaceVariables(OAuth2Options.java:579)
at io.vertx.ext.auth.oauth2.impl.OAuth2AuthProviderImpl.<init>(OAuth2AuthProviderImpl.java:64)
at io.vertx.ext.auth.oauth2.OAuth2Auth.create(OAuth2Auth.java:53)
At the very minimum, a more understandable exception should be thrown when passing in the map in the first place or when starting to replaceVariables.
To reproduce, I guess it's as easy doing the following in Kotlin:
val options = OAuth2Options()
options.setExtraParameters(JsonObject(mapOf("123" to "123"))
options.replaceVariables(true)
cheers,
Alef
p.s. it's not a pressing issue, I'm able to work around it by just adding the parameters one by one or passing in a mutable map
We should replace the underlying map on update, this also means we won't change user supplied state
Yes, that makes sense. Thanks!
Updated the milestone as there's some refactoring happening in ATM that touches the affected code.