dan-s1 commented on code in PR #8691:
URL: https://github.com/apache/nifi/pull/8691#discussion_r1643410235
##########
nifi-extension-bundles/nifi-network-bundle/nifi-network-processors/src/main/java/org/apache/nifi/processors/network/pcap/PCAPHeader.java:
##########
@@ -0,0 +1,95 @@
+// MIT License
+
+// Copyright (c) 2015-2024 Kaitai Project
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in
all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE
+// SOFTWARE.
+
+package org.apache.nifi.processors.network.pcap;
+
+public class PCAPHeader {
+ static final int PCAP_HEADER_LENGTH = 24;
+ private final ByteBufferReader io;
+ private final byte[] magicNumber;
+ private final int versionMajor;
+ private final int versionMinor;
+ private final int thiszone;
+ private final long sigfigs;
+ private final long snaplen;
+ private final long network;
+
+ public PCAPHeader(ByteBufferReader io) {
+ this.io = io;
+ this.magicNumber = this.io.readBytes(4);
+ this.versionMajor = this.io.readU2();
+ this.versionMinor = this.io.readU2();
+ this.thiszone = this.io.readS4();
+ this.sigfigs = this.io.readU4();
+ this.snaplen = this.io.readU4();
+ this.network = this.io.readU4();
+ }
+
+ public ByteBufferReader io() {
+ return io;
+ }
Review Comment:
It does not seem `io` is used anywhere else but the constructor. If that is
the case remove the instance variable and its getter method `io()`.
```suggestion
static final int PCAP_HEADER_LENGTH = 24;
private final byte[] magicNumber;
private final int versionMajor;
private final int versionMinor;
private final int thiszone;
private final long sigfigs;
private final long snaplen;
private final long network;
public PCAPHeader(ByteBufferReader io) {
this.magicNumber = io.readBytes(4);
this.versionMajor = io.readU2();
this.versionMinor = io.readU2();
this.thiszone = io.readS4();
this.sigfigs = io.readU4();
this.snaplen = io.readU4();
this.network = io.readU4();
}
```
--
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]