Skip to content

Commit

Permalink
Correctly implement equals / hashCode method for our SSLSession imple… (
Browse files Browse the repository at this point in the history
java-native-access#666)

…mentation

Motivation:

We should just take the id into account for equality and hashcode

Modifications:

Add implementation

Result:

Correctly handle hashCode and equals
  • Loading branch information
normanmaurer authored Feb 9, 2024
1 parent e4a4a5c commit c9c4ab5
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.nio.ByteBuffer;
import java.security.Principal;
import java.security.cert.Certificate;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -565,5 +566,22 @@ public int getPacketBufferSize() {
public int getApplicationBufferSize() {
return -1;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
QuicheQuicSslSession that = (QuicheQuicSslSession) o;
return Arrays.equals(getId(), that.getId());
}

@Override
public int hashCode() {
return Arrays.hashCode(getId());
}
}
}

0 comments on commit c9c4ab5

Please sign in to comment.