Skip to content

Commit

Permalink
Remove redundant transformation
Browse files Browse the repository at this point in the history
Signed-off-by: Rishab Nahata <[email protected]>
  • Loading branch information
imRishN committed Jun 8, 2023
1 parent 4c52178 commit 242c3ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Compress and cache cluster state during validate join request ([#7321](https://github.com/opensearch-project/OpenSearch/pull/7321))
- [Snapshot Interop] Add Changes in Create Snapshot Flow for remote store interoperability. ([#7118](https://github.com/opensearch-project/OpenSearch/pull/7118))
- Add new query profile collector fields with concurrent search execution ([#7898](https://github.com/opensearch-project/OpenSearch/pull/7898))
- Check UTF16 string size before converting to String to avoid OOME ([#7963](https://github.com/opensearch-project/OpenSearch/pull/7963))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,12 @@ public void writeTo(OutputStream os) throws IOException {
@Override
public String utf8ToString() {
BytesRef bytesRef = toBytesRef();
char[] ref = new char[bytesRef.length];
int len = UnicodeUtil.UTF8toUTF16(bytesRef.bytes, bytesRef.offset, bytesRef.length, ref);
final char[] ref = new char[bytesRef.length];
final int len = UnicodeUtil.UTF8toUTF16(bytesRef.bytes, bytesRef.offset, bytesRef.length, ref);
if (len > MAX_LENGTH) {
throw new IllegalStateException("UTF16 String size is " + len +
", should be less than " + MAX_LENGTH);
throw new IllegalStateException("UTF16 String size is " + len + ", should be less than " + MAX_LENGTH);
}
return bytesRef.utf8ToString();
return new String(ref, 0, len);
}

@Override
Expand Down

0 comments on commit 242c3ce

Please sign in to comment.