Skip to content

Commit

Permalink
more PR cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Nicholas Walter Knize <[email protected]>
  • Loading branch information
nknize committed Jun 19, 2023
1 parent ba1715e commit 2843bb2
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
* @opensearch.internal
*/
public final class ExceptionsHelper {
protected static final Logger logger = LogManager.getLogger(ExceptionsHelper.class);
private static final Logger logger = LogManager.getLogger(ExceptionsHelper.class);

// utility class: no ctor
private ExceptionsHelper() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.io.IOException;

import static org.opensearch.ExceptionsHelper.detailedMessage;
import static org.opensearch.OpenSearchException.generateThrowableXContent;
import static org.opensearch.core.xcontent.ConstructingObjectParser.constructorArg;

/**
Expand Down Expand Up @@ -93,7 +94,7 @@ public DefaultShardOperationFailedException(OpenSearchException e) {
}

public DefaultShardOperationFailedException(String index, int shardId, Throwable cause) {
super(index, shardId, ExceptionsHelper.detailedMessage(cause), ExceptionsHelper.status(cause), cause);
super(index, shardId, detailedMessage(cause), ExceptionsHelper.status(cause), cause);
}

public static DefaultShardOperationFailedException readShardOperationFailed(StreamInput in) throws IOException {
Expand Down Expand Up @@ -135,7 +136,7 @@ protected XContentBuilder innerToXContent(XContentBuilder builder, Params params
builder.field("status", status.name());
if (reason != null) {
builder.startObject("reason");
OpenSearchException.generateThrowableXContent(builder, params, cause);
generateThrowableXContent(builder, params, cause);
builder.endObject();
}
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.opensearch.OpenSearchException;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentLocation;
import org.opensearch.core.xcontent.XContentParser;
Expand Down Expand Up @@ -112,7 +111,7 @@ public RestStatus status() {
}

@Override
protected void metadataToXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
protected void metadataToXContent(XContentBuilder builder, Params params) throws IOException {
if (lineNumber != UNKNOWN_POSITION) {
builder.field("line", lineNumber);
builder.field("col", columnNumber);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

package org.opensearch.common.io.stream;

import org.opensearch.core.common.io.StreamsUtil;

import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -80,7 +78,7 @@ public byte readByte() throws IOException {
@Override
public void readBytes(byte[] b, int offset, int len) throws IOException {
if (len < 0) throw new IndexOutOfBoundsException();
final int read = StreamsUtil.readFully(is, b, offset, len);
final int read = is.readNBytes(b, offset, len);
if (read != len) {
throw new EOFException();
}
Expand Down

This file was deleted.

3 changes: 1 addition & 2 deletions server/src/main/java/org/opensearch/common/io/Streams.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.opensearch.common.io.stream.BytesStream;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.StreamsUtil;

import java.io.BufferedReader;
import java.io.FilterInputStream;
Expand Down Expand Up @@ -165,7 +164,7 @@ public static String copyToString(Reader in) throws IOException {

@Deprecated
public static int readFully(InputStream reader, byte[] dest) throws IOException {
return StreamsUtil.readFully(reader, dest, 0, dest.length);
return reader.readNBytes(dest, 0, dest.length);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions server/src/main/java/org/opensearch/index/store/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
import org.opensearch.common.util.concurrent.RefCounted;
import org.opensearch.common.util.iterable.Iterables;
import org.opensearch.common.util.io.IOUtils;
import org.opensearch.core.common.io.StreamsUtil;
import org.opensearch.env.NodeEnvironment;
import org.opensearch.env.ShardLock;
import org.opensearch.env.ShardLockObtainFailedException;
Expand Down Expand Up @@ -1240,7 +1239,7 @@ public static void hashFile(BytesRefBuilder fileHash, InputStream in, long size)
final int len = (int) Math.min(1024 * 1024, size); // for safety we limit this to 1MB
fileHash.grow(len);
fileHash.setLength(len);
final int readBytes = StreamsUtil.readFully(in, fileHash.bytes(), 0, len);
final int readBytes = in.readNBytes(fileHash.bytes(), 0, len);
assert readBytes == len : Integer.toString(readBytes) + " != " + Integer.toString(len);
assert fileHash.length() == len : Integer.toString(fileHash.length()) + " != " + Integer.toString(len);
}
Expand Down

0 comments on commit 2843bb2

Please sign in to comment.