greyp9 commented on a change in pull request #5420:
URL: https://github.com/apache/nifi/pull/5420#discussion_r718551880



##########
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server/src/main/java/org/apache/nifi/distributed/cache/server/DistributedCacheServer.java
##########
@@ -68,6 +68,13 @@
         .required(false)
         .addValidator(StandardValidators.createDirectoryExistsValidator(true, 
true))
         .build();
+    public static final PropertyDescriptor MAX_READ_SIZE = new 
PropertyDescriptor.Builder()
+        .name("Maximum Read Size")

Review comment:
       Cool; now I understand the PR template instructions.  TIL!

##########
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server/src/main/java/org/apache/nifi/distributed/cache/server/map/MapCacheServer.java
##########
@@ -251,10 +251,17 @@ protected void finalize() throws Throwable {
     }
 
     private byte[] readValue(final DataInputStream dis) throws IOException {
-        final int numBytes = dis.readInt();
+        final int numBytes = validateInt(dis.readInt(), getMaxReadSize(), 
"readValue():");
         final byte[] buffer = new byte[numBytes];
         dis.readFully(buffer);
         return buffer;
     }
 
+    private int validateInt(final int value, final int max, final String 
identifier) throws IOException {
+        if (value <= max) {
+            return value;
+        } else {
+            throw new IOException(new IllegalArgumentException(identifier + 
value));
+        }
+    }

Review comment:
       I was thinking the same thing :)

##########
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-client-service/src/main/java/org/apache/nifi/distributed/cache/client/CacheClientRequestHandler.java
##########
@@ -64,6 +64,18 @@ public void channelReadComplete(ChannelHandlerContext ctx) 
throws IOException {
         }
     }
 
+    @Override
+    public void channelUnregistered(ChannelHandlerContext ctx) {

Review comment:
       Thanks.  I'm used to this check occurring in the Maven build.  I dug 
into my IDE settings and found the place to flag this.




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


Reply via email to