You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by GitBox <gi...@apache.org> on 2020/09/12 16:47:50 UTC
[GitHub] [thrift] Jens-G commented on a change in pull request #2191: THRIFT-5237 Implement MAX_MESSAGE_SIZE and consolidate limits into a TConfiguration class(JAVA)
Jens-G commented on a change in pull request #2191:
URL: https://github.com/apache/thrift/pull/2191#discussion_r487426110
##########
File path: lib/java/src/org/apache/thrift/protocol/TCompactProtocol.java
##########
@@ -37,868 +38,930 @@
* and i64 fields you have, the more benefit you'll see.
*/
public class TCompactProtocol extends TProtocol {
- private final static byte[] EMPTY_BYTES = new byte[0];
- private final static ByteBuffer EMPTY_BUFFER = ByteBuffer.wrap(EMPTY_BYTES);
-
- private final static long NO_LENGTH_LIMIT = -1;
-
- private final static TStruct ANONYMOUS_STRUCT = new TStruct("");
- private final static TField TSTOP = new TField("", TType.STOP, (short)0);
-
- private final static byte[] ttypeToCompactType = new byte[16];
-
- static {
- ttypeToCompactType[TType.STOP] = TType.STOP;
- ttypeToCompactType[TType.BOOL] = Types.BOOLEAN_TRUE;
- ttypeToCompactType[TType.BYTE] = Types.BYTE;
- ttypeToCompactType[TType.I16] = Types.I16;
- ttypeToCompactType[TType.I32] = Types.I32;
- ttypeToCompactType[TType.I64] = Types.I64;
- ttypeToCompactType[TType.DOUBLE] = Types.DOUBLE;
- ttypeToCompactType[TType.STRING] = Types.BINARY;
- ttypeToCompactType[TType.LIST] = Types.LIST;
- ttypeToCompactType[TType.SET] = Types.SET;
- ttypeToCompactType[TType.MAP] = Types.MAP;
- ttypeToCompactType[TType.STRUCT] = Types.STRUCT;
- }
-
- /**
- * TProtocolFactory that produces TCompactProtocols.
- */
- public static class Factory implements TProtocolFactory {
+ private final static byte[] EMPTY_BYTES = new byte[0];
+ private final static ByteBuffer EMPTY_BUFFER = ByteBuffer.wrap(EMPTY_BYTES);
+
+ private final static long NO_LENGTH_LIMIT = -1;
+
+ private final static TStruct ANONYMOUS_STRUCT = new TStruct("");
+ private final static TField TSTOP = new TField("", TType.STOP, (short) 0);
+
+ private final static byte[] ttypeToCompactType = new byte[16];
+
+ static {
+ ttypeToCompactType[TType.STOP] = TType.STOP;
+ ttypeToCompactType[TType.BOOL] = Types.BOOLEAN_TRUE;
+ ttypeToCompactType[TType.BYTE] = Types.BYTE;
+ ttypeToCompactType[TType.I16] = Types.I16;
Review comment:
Why all those whitespace changes? The patch is already large enough without these ;-)
##########
File path: lib/java/test/org/apache/thrift/transport/TestAutoExpandingBufferWriteTransport.java
##########
@@ -19,14 +19,16 @@
package org.apache.thrift.transport;
import java.nio.ByteBuffer;
+
+import org.apache.thrift.TConfiguration;
import org.junit.Test;
import static org.junit.Assert.*;
public class TestAutoExpandingBufferWriteTransport {
@Test
public void testIt() throws Exception {
- AutoExpandingBufferWriteTransport t = new AutoExpandingBufferWriteTransport(1, 0);
+ AutoExpandingBufferWriteTransport t = new AutoExpandingBufferWriteTransport(new TConfiguration(), 1, 0);
Review comment:
Nut sure but .... wouldnt it be better to instantiate TConfiguration() only once and use it through the whole test case or at least inside the method?
##########
File path: lib/java/src/org/apache/thrift/transport/layered/TFramedTransport.java
##########
@@ -138,22 +135,24 @@ public void clear() {
private final byte[] i32buf = new byte[4];
private void readFrame() throws TTransportException {
- transport_.readAll(i32buf, 0, 4);
+ getInnerTransport().readAll(i32buf, 0, 4);
int size = decodeFrameSize(i32buf);
if (size < 0) {
close();
throw new TTransportException(TTransportException.CORRUPTED_DATA, "Read a negative frame size (" + size + ")!");
}
- if (size > maxLength_) {
+ if (size > getInnerTransport().getConfiguration().getMaxFrameSize()) {
close();
throw new TTransportException(TTransportException.CORRUPTED_DATA,
- "Frame size (" + size + ") larger than max length (" + maxLength_ + ")!");
+ "Frame size (" + size + ") larger than max length (" + getInnerTransport().getConfiguration().getMaxFrameSize() + ")!");
}
+ //updateKnownMessageSize(size);
Review comment:
Added but commented out?
##########
File path: lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java
##########
@@ -279,6 +280,10 @@ public void readFieldEnd() throws TException {}
@Override
public TMap readMapBegin() throws TException {
TMap map = new TMap(readByte(), readByte(), readI32());
+
+ //
Review comment:
there are quite a few emtpy comment lines in here, is there sth missing?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org