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

equals() for TokenDetails is broken #926

Closed
ikbalkaya opened this issue Mar 17, 2023 · 1 comment · Fixed by #927
Closed

equals() for TokenDetails is broken #926

ikbalkaya opened this issue Mar 17, 2023 · 1 comment · Fixed by #927
Assignees
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@ikbalkaya
Copy link
Contributor

ikbalkaya commented Mar 17, 2023

Following is how equals has been implemented for TokenDetails

 @Override
   public boolean equals(Object obj) {
            TokenDetails details = (TokenDetails)obj;
            return equalNullableStrings(this.token, details.token) &
                    equalNullableStrings(this.capability, details.capability) &
                    equalNullableStrings(this.clientId, details.clientId) &
                    (this.issued == details.issued) &
                    (this.expires == details.expires);
        }    

This implementation doesn't take into account when obj is null or not the type of token details.

Expected
Return false when obj is null or a different type

Spotted:
Flutter plugin Stream writer does this check when writing types to streams

protected void writeValue(@NonNull ByteArrayOutputStream stream, @Nullable Object value) {
    if (value == null || value.equals(null)) {
      stream.write(NULL);
@ikbalkaya ikbalkaya added the bug Something isn't working. It's clear that this does need to be fixed. label Mar 17, 2023
@sync-by-unito
Copy link

sync-by-unito bot commented Mar 17, 2023

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3465

@ikbalkaya ikbalkaya changed the title TokenDetails equals() is broken equals() for TokenDetails is broken Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

Successfully merging a pull request may close this issue.

1 participant