szetszwo commented on code in PR #716:
URL: https://github.com/apache/ratis/pull/716#discussion_r983215680
##########
ratis-common/src/main/java/org/apache/ratis/datastream/impl/DataStreamRequestByteBuffer.java:
##########
@@ -17,31 +17,31 @@
*/
package org.apache.ratis.datastream.impl;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.ratis.io.WriteOption;
import org.apache.ratis.protocol.DataStreamRequest;
import org.apache.ratis.protocol.DataStreamRequestHeader;
+import org.apache.ratis.thirdparty.com.google.common.collect.Lists;
import org.apache.ratis.util.Preconditions;
import java.nio.ByteBuffer;
+import java.util.List;
/**
* Implements {@link DataStreamRequest} with {@link ByteBuffer}.
*
* This class is immutable.
*/
public class DataStreamRequestByteBuffer extends DataStreamPacketByteBuffer
implements DataStreamRequest {
- private WriteOption[] options;
+ private List<WriteOption> options;
public DataStreamRequestByteBuffer(DataStreamRequestHeader header,
ByteBuffer buffer) {
super(header.getClientId(), header.getType(), header.getStreamId(),
header.getStreamOffset(), buffer);
- this.options = header.getWriteOptions();
+ this.options = Lists.newArrayList(header.getWriteOptionsList());
Preconditions.assertTrue(header.getDataLength() == buffer.remaining());
}
@Override
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public WriteOption[] getWriteOptions() {
- return options;
+ public List<WriteOption> getWriteOptionsList() {
+ return Lists.newArrayList(options);
Review Comment:
Please make the list immutable and don't copy the list for each get
operation.
##########
ratis-common/src/main/java/org/apache/ratis/protocol/DataStreamRequest.java:
##########
@@ -19,7 +19,9 @@
package org.apache.ratis.protocol;
import org.apache.ratis.io.WriteOption;
+import java.util.List;
public interface DataStreamRequest extends DataStreamPacket {
- WriteOption[] getWriteOptions();
Review Comment:
This is a public interface. We must first deprecate it before removing it
later.
##########
ratis-common/src/main/java/org/apache/ratis/protocol/DataStreamRequest.java:
##########
@@ -19,7 +19,9 @@
package org.apache.ratis.protocol;
import org.apache.ratis.io.WriteOption;
+import java.util.List;
public interface DataStreamRequest extends DataStreamPacket {
- WriteOption[] getWriteOptions();
+
+ List<WriteOption> getWriteOptionsList();
Review Comment:
Rename "getWriteOptionsList" to "getWriteOptionList".
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]