You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2021/09/09 15:22:56 UTC

[sling-org-apache-sling-commons-clam] 16/25: [checkstyle] (coding) MagicNumber

This is an automated email from the ASF dual-hosted git repository.

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-clam.git

commit aeeb4f4b8eb535f19573ca109a20f98bd43b38bd
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Wed Sep 8 22:04:47 2021 +0200

    [checkstyle] (coding) MagicNumber
---
 .../java/org/apache/sling/commons/clam/internal/ClamdService.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/commons/clam/internal/ClamdService.java b/src/main/java/org/apache/sling/commons/clam/internal/ClamdService.java
index ff1d5f1..3a42143 100644
--- a/src/main/java/org/apache/sling/commons/clam/internal/ClamdService.java
+++ b/src/main/java/org/apache/sling/commons/clam/internal/ClamdService.java
@@ -74,6 +74,9 @@ public final class ClamdService implements ClamService, ContentAnalyzer {
 
     private static final String INSTREAM_SIZE_LIMIT_EXCEEDED_PATTERN = "INSTREAM size limit exceeded. ERROR";
 
+    // length is the size of the following data in bytes expressed as a 4 byte unsigned integer in network byte order
+    private static final int CHUNK_LENGTH_DATUM_SIZE = 4;
+
     private final Logger logger = LoggerFactory.getLogger(ClamdService.class);
 
     public ClamdService() { //
@@ -196,7 +199,7 @@ public final class ClamdService implements ClamService, ContentAnalyzer {
             while (read >= 0) {
                 logger.trace("current chunk length: {}", read);
                 total = total + read;
-                final byte[] length = ByteBuffer.allocate(4).putInt(read).array();
+                final byte[] length = ByteBuffer.allocate(CHUNK_LENGTH_DATUM_SIZE).putInt(read).array();
 
                 out.write(length);
                 out.write(data, 0, read);