Skip to content

Commit

Permalink
enh: refactor value comparison in Netty5HeadersAdapter
Browse files Browse the repository at this point in the history
The method `containsValue` in `Netty5HeadersAdapter` has been refactored. It now converts the input value and the entry value into the string prior to comparison. This approach optimizes accuracy, preventing false positives when a CharSequence object is passed in that isn't a string.
  • Loading branch information
alidandach committed Mar 15, 2024
1 parent 214a54d commit ba42d63
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ public boolean containsKey(Object key) {

@Override
public boolean containsValue(Object value) {
return (value instanceof String &&
StreamSupport.stream(this.headers.spliterator(), false)
.anyMatch(entry -> value.equals(entry.getValue())));
if (value instanceof CharSequence) {
String valueStr = value.toString();
return StreamSupport.stream(this.headers.spliterator(), false)
.anyMatch(entry -> valueStr.equals(entry.getValue().toString()));
}
return false;
}

@Override
Expand Down

0 comments on commit ba42d63

Please sign in to comment.