Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryParam Backcompat #1587

Merged
merged 6 commits into from
Oct 8, 2021
Merged

QueryParam Backcompat #1587

merged 6 commits into from
Oct 8, 2021

Conversation

rpdome
Copy link
Member

@rpdome rpdome commented Oct 8, 2021

Older MSAL/Common serializes broker request request from Pair.

Even though we're ditching Pair already (for common4j - Pair is an android class), we need to be still able to support it.

@rpdome rpdome force-pushed the rapong/fixQueryParamClass branch 2 times, most recently from 6a4e848 to cb20b48 Compare October 8, 2021 16:21
@rpdome rpdome added the No-Changelog This Pull-Request has no associated changelog entry. label Oct 8, 2021
Copy link
Contributor

@AdamBJohnsonx AdamBJohnsonx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're trying to write the most efficient form, which should abstract away the type. Before we do this, we should understand why that's not happening.

*/
public class QueryParamsAdapter extends TypeAdapter<List<Map.Entry<String, String>>> {
public class QueryParamsAdapter extends TypeAdapter<List<Pair<String, String>>> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this now work with new MSAL? I suppose that's going to send Map.Entry?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the new MSAL (not in prod) sends Map.Entry, the old one sends Pair.

Please also read the finding i just added below - this TypeAdapter is never properly used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should document this in the release notes for MSAL/ADAL.. As part of how to upgrade to new major version.
right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with this change now even new one sends Pair..so I don't expect there to be any changes needed for upgrade. @rpdome can confirm.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. no change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the new one will serialize Map.Entry into the very same format as Pair.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to make this change in Authenticator code, with the first RC build, that's why I thought..
Maybe I will need to revert that with the new RC build :)

@rpdome
Copy link
Member Author

rpdome commented Oct 8, 2021

@AdamBJohnsonx Unfortunately, we shipped a bug from the beginning - we're supposed to specify the TypeToken of List<Pair> or List<Map.Entry> in the first parameter instead, this means that this adapter is never used, so gson has always used it default adapter from the get go.

This means we're stuck with it, unless we want to make a broker-msal protocol breaking change.

If we migrate to the right format {"eqp1":"1", "eqp2":"2"}, then it will break when MSAL is trying to talk to the older broker (which expects the pair format)

To prevent the confusion, I'll just kill the adapter.

@rpdome
Copy link
Member Author

rpdome commented Oct 8, 2021

Alternatively, i could make the adapter of List<Map.Entry> to return List's format.

@shahzaibj
Copy link
Contributor

@AdamBJohnsonx Unfortunately, we shipped a bug from the beginning - we're supposed to specify the TypeToken of List or List instead, this means that this adapter is never used, so gson has always used it default adapter from the get go.

This means we're stuck with it, unless we want to make a broker-msal protocol breaking change.

If we migrate to the right format {"eqp1":"1", "eqp2":"2"}, then it will break when MSAL is trying to talk to the older broker (which expects the pair format)

To prevent the confusion, I'll just kill the adapter.

What does GSON default adapter do? I suppose it is handling Pair correctly? Can the default not handle Map.Entry?

@rpdome
Copy link
Member Author

rpdome commented Oct 8, 2021

@AdamBJohnsonx Unfortunately, we shipped a bug from the beginning - we're supposed to specify the TypeToken of List or List instead, this means that this adapter is never used, so gson has always used it default adapter from the get go.
This means we're stuck with it, unless we want to make a broker-msal protocol breaking change.
If we migrate to the right format {"eqp1":"1", "eqp2":"2"}, then it will break when MSAL is trying to talk to the older broker (which expects the pair format)
To prevent the confusion, I'll just kill the adapter.

What does GSON default adapter do? I suppose it is handling Pair correctly? Can the default not handle Map.Entry?

you get something like this

pair: [{"first":"eqp1","second":"1"},{"first":"eqp2","second":"2"}]
map: [{"key":"eqp1","value":"1"},{"key":"eqp2","value":"2"}]

The default can handle map, but we're stuck with the pair format (since there will always be older MSAL sending it, or an older Broker that expects it)

@rpdome rpdome requested a review from shahzaibj October 8, 2021 17:52
@AdamBJohnsonx
Copy link
Contributor

Alternatively, i could make the adapter of List<Map.Entry> to return List's format.

Bleah. So the thing you *can * do is to code the read side of this adapter so that it can understand any of these formats, rev the broker protocol version for the compact format, and choose how you want to send it. We should definitely break any tie between the structure of code being used to hold the data and how that data is transmitted and understood, however it happens.

Copy link
Contributor

@shahzaibj shahzaibj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@rpdome rpdome requested a review from shahzaibj October 8, 2021 20:16
@rpdome rpdome merged commit 86e3aea into dev Oct 8, 2021
@rpdome rpdome deleted the rapong/fixQueryParamClass branch October 8, 2021 22:14
@rpdome rpdome mentioned this pull request Oct 8, 2021
rpdome added a commit that referenced this pull request Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No-Changelog This Pull-Request has no associated changelog entry.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants