Fokko commented on code in PR #3359:
URL: https://github.com/apache/parquet-java/pull/3359#discussion_r2556526524


##########
parquet-format-structures/src/main/java/org/apache/parquet/format/Util.java:
##########
@@ -358,26 +392,54 @@ public void consume(RowGroup rowGroup) {
         byte[] plainText = decryptor.decrypt(input, AAD);
         from = new ByteArrayInputStream(plainText);
       }
-      new EventBasedThriftReader(protocol(from)).readStruct(eventConsumer);
+      new EventBasedThriftReader(protocol(from, 
maxMessageSize)).readStruct(eventConsumer);
     } catch (TException e) {
       throw new IOException("can not read FileMetaData: " + e.getMessage(), e);
     }
   }
 
   private static TProtocol protocol(OutputStream to) throws 
TTransportException {
-    return protocol(new TIOStreamTransport(to));
+    return protocol(new TIOStreamTransport(to), -1);
   }
 
   private static TProtocol protocol(InputStream from) throws 
TTransportException {
-    return protocol(new TIOStreamTransport(from));
+    return protocol(new TIOStreamTransport(from), -1);
+  }
+
+  private static TProtocol protocol(InputStream from, int maxMessageSize) 
throws TTransportException {
+    return protocol(new TIOStreamTransport(from), maxMessageSize);
   }
 
-  private static InterningProtocol protocol(TIOStreamTransport t) {
+  private static InterningProtocol protocol(TIOStreamTransport t, int 
configuredMaxMessageSize)
+      throws TTransportException, NumberFormatException {
+    int maxMessageSize = configuredMaxMessageSize;
+    if (configuredMaxMessageSize == -1) {
+      // Set to default 100 MB
+      maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE;
+    }
+    if (configuredMaxMessageSize < -1 || configuredMaxMessageSize == 0) {
+      throw new NumberFormatException("Invalid max message size: " + 
configuredMaxMessageSize);

Review Comment:
   ```suggestion
       if (configuredMaxMessageSize <= 0) {
         throw new NumberFormatException("Max message size must be positive: " 
+ configuredMaxMessageSize);
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to