You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2022/09/02 09:22:19 UTC

[plc4x] branch develop updated: fix(plc4j): remove e.printStackTrace() calls

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

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new e898b7b95 fix(plc4j): remove e.printStackTrace() calls
e898b7b95 is described below

commit e898b7b9542520f7f03908b327794c641657187d
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Sep 2 11:22:11 2022 +0200

    fix(plc4j): remove e.printStackTrace() calls
---
 .../modbus/tcp/discovery/ModbusPlcDiscoverer.java  |   8 +-
 .../java/opcua/context/EncryptionHandler.java      |   9 +-
 .../plc4x/java/opcua/context/SecureChannel.java    |  36 ++---
 .../java/opcua/protocol/OpcuaProtocolLogic.java    |  39 +++---
 .../plc4x/java/opcua/OpcuaPlcDriverTest.java       | 150 ++++++++++-----------
 .../profinet/protocol/ProfinetProtocolLogic.java   |  19 +--
 .../utils/rawsockets/netty/utils/ArpUtils.java     |  18 +--
 7 files changed, 127 insertions(+), 152 deletions(-)

diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/discovery/ModbusPlcDiscoverer.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/discovery/ModbusPlcDiscoverer.java
index eafa99e0f..bca94797b 100644
--- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/discovery/ModbusPlcDiscoverer.java
+++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/discovery/ModbusPlcDiscoverer.java
@@ -18,6 +18,7 @@
  */
 package org.apache.plc4x.java.modbus.tcp.discovery;
 
+import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
 import org.apache.plc4x.java.api.messages.PlcDiscoveryItem;
 import org.apache.plc4x.java.api.messages.PlcDiscoveryItemHandler;
 import org.apache.plc4x.java.api.messages.PlcDiscoveryRequest;
@@ -57,6 +58,7 @@ public class ModbusPlcDiscoverer implements PlcDiscoverer {
         Set<Object> seen = ConcurrentHashMap.newKeySet();
         return t -> seen.add(keyExtractor.apply(t));
     }
+
     @Override
     public CompletableFuture<PlcDiscoveryResponse> discover(PlcDiscoveryRequest discoveryRequest) {
         return discoverWithHandler(discoveryRequest, null);
@@ -92,7 +94,7 @@ public class ModbusPlcDiscoverer implements PlcDiscoverer {
         try {
             possibleAddresses.add(InetAddress.getByName("localhost"));
         } catch (UnknownHostException e) {
-            e.printStackTrace();
+            throw new PlcRuntimeException(e);
         }
 
         // Filter out duplicates.
@@ -128,7 +130,7 @@ public class ModbusPlcDiscoverer implements PlcDiscoverer {
                 // TODO: We should probably not only try to read a coil, but try any of the types and if one works, that's a match.
                 // Possibly we can fine tune this to speed up things.
                 int transactionIdentifier = 1;
-                for(short unitIdentifier = 1; unitIdentifier <= 247; unitIdentifier++) {
+                for (short unitIdentifier = 1; unitIdentifier <= 247; unitIdentifier++) {
                     ModbusTcpADU packet = new ModbusTcpADU(transactionIdentifier++, unitIdentifier,
                         new ModbusPDUReadCoilsRequest(1, 1), false);
                     byte[] deviceIdentificationBytes = null;
@@ -208,7 +210,7 @@ public class ModbusPlcDiscoverer implements PlcDiscoverer {
                                 discoveryItems.add(discoveryItem);
 
                                 // Give a handler the chance to react on the found device.
-                                if(handler != null) {
+                                if (handler != null) {
                                     handler.handle(discoveryItem);
                                 }
                                 break;
diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/EncryptionHandler.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/EncryptionHandler.java
index 8c3e41009..a841d653e 100644
--- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/EncryptionHandler.java
+++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/EncryptionHandler.java
@@ -159,8 +159,7 @@ public class EncryptionHandler {
                 }
             }
         } catch (Exception e) {
-            LOGGER.error("Unable to decrypt Data");
-            e.printStackTrace();
+            LOGGER.error("Unable to decrypt Data", e);
         }
     }
 
@@ -183,8 +182,7 @@ public class EncryptionHandler {
             cipher.init(Cipher.ENCRYPT_MODE, this.serverCertificate.getPublicKey());
             return cipher.doFinal(data);
         } catch (Exception e) {
-            LOGGER.error("Unable to encrypt Data");
-            e.printStackTrace();
+            LOGGER.error("Unable to encrypt Data", e);
             return null;
         }
     }
@@ -212,8 +210,7 @@ public class EncryptionHandler {
             SecretKeySpec keySpec = new SecretKeySpec(getSecretKey(), "HmacSHA256");
             cipher.init(keySpec);
         } catch (Exception e) {
-            LOGGER.error("Unable to encrypt Data");
-            e.printStackTrace();
+            LOGGER.error("Unable to encrypt Data", e);
         }
     }
 
diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java
index 9cf7565dd..a92442724 100644
--- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java
+++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java
@@ -347,12 +347,11 @@ public class SecureChannel {
                                 channelId.set((int) ((ChannelSecurityToken) openSecureChannelResponse.getSecurityToken()).getChannelId());
                                 onConnectCreateSessionRequest(context);
                             } catch (PlcConnectionException e) {
-                                LOGGER.error("Error occurred while connecting to OPC UA server");
-                                e.printStackTrace();
+                                LOGGER.error("Error occurred while connecting to OPC UA server", e);
                             }
                         }
                     } catch (ParseException e) {
-                        e.printStackTrace();
+                        LOGGER.error("Error parsing", e);
                     }
                 });
             LOGGER.debug("Submitting OpenSecureChannel with id of {}", transactionId);
@@ -450,7 +449,7 @@ public class SecureChannel {
                         }
                     }
                 } catch (ParseException e) {
-                    e.printStackTrace();
+                    LOGGER.error("Error parsing", e);
                 }
 
             };
@@ -461,8 +460,7 @@ public class SecureChannel {
             };
 
             BiConsumer<OpcuaAPU, Throwable> error = (message, e) -> {
-                LOGGER.error("Error while waiting for subscription response");
-                e.printStackTrace();
+                LOGGER.error("Error while waiting for subscription response", e);
             };
 
             submit(context, timeout, error, consumer, buffer);
@@ -561,29 +559,26 @@ public class SecureChannel {
                                 LOGGER.error("Subscription ServiceFault returned from server with error code,  '{}'", header.getServiceResult().toString());
                             }
                         } catch (ParseException e) {
-                            LOGGER.error("Unable to parse the returned Subscription response");
-                            e.printStackTrace();
+                            LOGGER.error("Unable to parse the returned Subscription response", e);
                         }
                     }
                 } catch (ParseException e) {
-                    e.printStackTrace();
+                    LOGGER.error("Error parsing", e);
                 }
 
             };
 
             Consumer<TimeoutException> timeout = e -> {
-                LOGGER.error("Timeout while waiting for activate session response");
-                e.printStackTrace();
+                LOGGER.error("Timeout while waiting for activate session response", e);
             };
 
             BiConsumer<OpcuaAPU, Throwable> error = (message, e) -> {
-                LOGGER.error("Error while waiting for activate session response");
-                e.printStackTrace();
+                LOGGER.error("Error while waiting for activate session response", e);
             };
 
             submit(context, timeout, error, consumer, buffer);
         } catch (SerializationException e) {
-            LOGGER.error("Unable to to Parse Activate Session Request");
+            LOGGER.error("Unable to to Parse Activate Session Request", e);
         }
     }
 
@@ -652,24 +647,22 @@ public class SecureChannel {
                         }
                     }
                 } catch (ParseException e) {
-                    e.printStackTrace();
+                    LOGGER.error("Error parsing", e);
                 }
 
             };
 
             Consumer<TimeoutException> timeout = e -> {
-                LOGGER.error("Timeout while waiting for close session response");
-                e.printStackTrace();
+                LOGGER.error("Timeout while waiting for close session response", e);
             };
 
             BiConsumer<OpcuaAPU, Throwable> error = (message, e) -> {
-                LOGGER.error("Error while waiting for close session response");
-                e.printStackTrace();
+                LOGGER.error("Error while waiting for close session response", e);
             };
 
             submit(context, timeout, error, consumer, buffer);
         } catch (SerializationException e) {
-            LOGGER.error("Unable to to Parse Close Session Request");
+            LOGGER.error("Unable to to Parse Close Session Request", e);
         }
     }
 
@@ -745,7 +738,6 @@ public class SecureChannel {
     }
 
 
-
     public void onDiscoverOpenSecureChannel(ConversationContext<OpcuaAPU> context, OpcuaAcknowledgeResponse opcuaAcknowledgeResponse) {
         int transactionId = channelTransactionManager.getTransactionIdentifier();
 
@@ -908,7 +900,7 @@ public class SecureChannel {
                             onDiscoverCloseSecureChannel(context, response);
                         }
                     } catch (ParseException e) {
-                        e.printStackTrace();
+                        LOGGER.error("Error parsing", e);
                     }
                 });
 
diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java
index de2dbcca7..1af628a41 100644
--- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java
+++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java
@@ -41,6 +41,7 @@ import org.apache.plc4x.java.spi.values.IEC61131ValueHandler;
 import org.apache.plc4x.java.spi.values.PlcList;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import java.math.BigInteger;
 import java.time.Duration;
 import java.time.Instant;
@@ -57,7 +58,7 @@ import java.util.function.Consumer;
 public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements HasConfiguration<OpcuaConfiguration>, PlcSubscriber {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(OpcuaProtocolLogic.class);
-    protected static final PascalString NULL_STRING = new PascalString( "");
+    protected static final PascalString NULL_STRING = new PascalString("");
     private static ExpandedNodeId NULL_EXPANDED_NODEID = new ExpandedNodeId(false,
         false,
         new NodeIdTwoByte((short) 0),
@@ -138,7 +139,7 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H
 
         List<ExtensionObjectDefinition> readValueArray = new ArrayList<>(request.getFieldNames().size());
         Iterator<String> iterator = request.getFieldNames().iterator();
-        for (int i = 0; i < request.getFieldNames().size(); i++ ) {
+        for (int i = 0; i < request.getFieldNames().size(); i++) {
             String fieldName = iterator.next();
             OpcuaField field = (OpcuaField) request.getField(fieldName);
 
@@ -174,7 +175,7 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H
             extObject.serialize(buffer);
 
             /* Functional Consumer example using inner class */
-            Consumer<byte []> consumer = opcuaResponse -> {
+            Consumer<byte[]> consumer = opcuaResponse -> {
                 PlcReadResponse response = null;
                 try {
                     ExtensionObjectDefinition reply = ExtensionObject.staticParse(new ReadBufferByteBased(opcuaResponse, ByteOrder.LITTLE_ENDIAN), false).getBody();
@@ -197,7 +198,8 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H
                     }
                 } catch (ParseException e) {
                     future.completeExceptionally(new PlcRuntimeException(e));
-                };
+                }
+                ;
             };
 
             /* Functional Consumer example using inner class */
@@ -242,7 +244,7 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H
         PlcResponseCode responseCode = PlcResponseCode.OK;
         Map<String, ResponseItem<PlcValue>> response = new HashMap<>();
         int count = 0;
-        for ( String field : fieldNames ) {
+        for (String field : fieldNames) {
             PlcValue value = null;
             if (results.get(count).getValueSpecified()) {
                 Variant variant = results.get(count).getValue();
@@ -369,7 +371,7 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H
                         tmpValue[i] = strings.get(i).toString();
                     }
                     value = IEC61131ValueHandler.of(tmpValue);
-                }else if (variant instanceof VariantStatusCode) {
+                } else if (variant instanceof VariantStatusCode) {
                     int length = ((VariantStatusCode) variant).getValue().size();
                     List<StatusCode> strings = ((VariantStatusCode) variant).getValue();
                     String[] tmpValue = new String[length];
@@ -391,7 +393,7 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H
                     value = plcList;
                 } else {
                     responseCode = PlcResponseCode.UNSUPPORTED;
-                    LOGGER.error("Data type - " +  variant.getClass() + " is not supported ");
+                    LOGGER.error("Data type - " + variant.getClass() + " is not supported ");
                 }
             } else {
                 if (results.get(count).getStatusCode().getStatusCode() == OpcuaStatusCode.BadNodeIdUnknown.getValue()) {
@@ -658,7 +660,7 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H
             case "CHAR":
             case "STRING":
 
-            // UTF-16 Characters and Strings
+                // UTF-16 Characters and Strings
             case "WCHAR":
             case "WSTRING":
             case "STRING16":
@@ -755,7 +757,7 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H
                 try {
                     responseMessage = (WriteResponse) ExtensionObject.staticParse(new ReadBufferByteBased(opcuaResponse, ByteOrder.LITTLE_ENDIAN), false).getBody();
                 } catch (ParseException e) {
-                    e.printStackTrace();
+                    throw new PlcRuntimeException(e);
                 }
                 PlcWriteResponse response = writeResponse(request, responseMessage);
 
@@ -786,7 +788,7 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H
         Map<String, PlcResponseCode> responseMap = new HashMap<>();
         List<StatusCode> results = writeResponse.getResults();
         Iterator<String> responseIterator = request.getFieldNames().iterator();
-        for (int i = 0; i < request.getFieldNames().size(); i++ ) {
+        for (int i = 0; i < request.getFieldNames().size(); i++) {
             String fieldName = responseIterator.next();
             OpcuaStatusCode statusCode = OpcuaStatusCode.enumForValue(results.get(i).getStatusCode());
             switch (statusCode) {
@@ -809,7 +811,7 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H
         return CompletableFuture.supplyAsync(() -> {
             Map<String, ResponseItem<PlcSubscriptionHandle>> values = new HashMap<>();
             long subscriptionId;
-            ArrayList<String> fields = new ArrayList<>( subscriptionRequest.getFieldNames() );
+            ArrayList<String> fields = new ArrayList<>(subscriptionRequest.getFieldNames());
             long cycleTime = (subscriptionRequest.getField(fields.get(0))).getDuration().orElse(Duration.ofMillis(1000)).toMillis();
 
             try {
@@ -887,24 +889,21 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H
 
             /* Functional Consumer example using inner class */
             Consumer<TimeoutException> timeout = e -> {
-                LOGGER.error("Timeout while waiting on the crate subscription response");
-                e.printStackTrace();
+                LOGGER.error("Timeout while waiting on the crate subscription response", e);
                 // Pass the response back to the application.
                 future.completeExceptionally(e);
             };
 
             /* Functional Consumer example using inner class */
             BiConsumer<OpcuaAPU, Throwable> error = (message, e) -> {
-                LOGGER.error("Error while creating the subscription");
-                e.printStackTrace();
+                LOGGER.error("Error while creating the subscription", e);
                 // Pass the response back to the application.
                 future.completeExceptionally(e);
             };
 
             channel.submit(context, timeout, error, consumer, buffer);
         } catch (SerializationException e) {
-            LOGGER.error("Error while creating the subscription");
-            e.printStackTrace();
+            LOGGER.error("Error while creating the subscription", e);
             future.completeExceptionally(e);
         }
         return future;
@@ -946,8 +945,8 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H
 
     private GuidValue toGuidValue(String identifier) {
         LOGGER.error("Querying Guid nodes is not supported");
-        byte[] data4 = new byte[] {0,0};
-        byte[] data5 = new byte[] {0,0,0,0,0,0};
-        return new GuidValue(0L,0,0,data4, data5);
+        byte[] data4 = new byte[]{0, 0};
+        byte[] data5 = new byte[]{0, 0, 0, 0, 0, 0};
+        return new GuidValue(0L, 0, 0, data4, data5);
     }
 }
diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java
index 688135a53..17278c153 100644
--- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java
+++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java
@@ -130,55 +130,47 @@ public class OpcuaPlcDriverTest {
     private static ExampleServer exampleServer;
 
     @BeforeAll
-    public static void setup() {
+    public static void setup() throws Exception {
+        // When switching JDK versions from a newer to an older version,
+        // this can cause the server to not start correctly.
+        // Deleting the directory makes sure the key-store is initialized correctly.
+        Path securityBaseDir = Paths.get(System.getProperty("java.io.tmpdir"), "server", "security");
         try {
-            // When switching JDK versions from a newer to an older version,
-            // this can cause the server to not start correctly.
-            // Deleting the directory makes sure the key-store is initialized correctly.
-            Path securityBaseDir = Paths.get(System.getProperty("java.io.tmpdir"), "server", "security");
-            try {
-                Files.delete(securityBaseDir);
-            } catch (Exception e) {
-                // Ignore this ...
-            }
-
-            exampleServer = new ExampleServer();
-            exampleServer.startup().get();
+            Files.delete(securityBaseDir);
         } catch (Exception e) {
-            e.printStackTrace();
+            // Ignore this ...
         }
+
+        exampleServer = new ExampleServer();
+        exampleServer.startup().get();
     }
 
     @AfterAll
-    public static void tearDown() {
-        try {
-            if(exampleServer != null) {
-                exampleServer.shutdown().get();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
+    public static void tearDown() throws Exception {
+        if (exampleServer != null) {
+            exampleServer.shutdown().get();
         }
     }
 
     @Test
-    public void connectionNoParams(){
+    public void connectionNoParams() {
         connectionStringValidSet.forEach(connectionString -> {
-                try {
-                    PlcConnection opcuaConnection = new PlcDriverManager().getConnection(connectionString);
-                    Condition<PlcConnection> is_connected = new Condition<>(PlcConnection::isConnected, "is connected");
-                    assertThat(opcuaConnection).is(is_connected);
-                    opcuaConnection.close();
-                    assertThat(opcuaConnection).isNot(is_connected);
-                } catch (PlcConnectionException e) {
-                    fail("Exception during connectionNoParams while connecting Test EXCEPTION: " + e.getMessage());
-                } catch (Exception e) {
-                    fail("Exception during connectionNoParams while closing Test EXCEPTION: " + e.getMessage());
-                }
+            try {
+                PlcConnection opcuaConnection = new PlcDriverManager().getConnection(connectionString);
+                Condition<PlcConnection> is_connected = new Condition<>(PlcConnection::isConnected, "is connected");
+                assertThat(opcuaConnection).is(is_connected);
+                opcuaConnection.close();
+                assertThat(opcuaConnection).isNot(is_connected);
+            } catch (PlcConnectionException e) {
+                fail("Exception during connectionNoParams while connecting Test EXCEPTION: " + e.getMessage());
+            } catch (Exception e) {
+                fail("Exception during connectionNoParams while closing Test EXCEPTION: " + e.getMessage());
+            }
         });
     }
 
     @Test
-    public void connectionWithDiscoveryParam(){
+    public void connectionWithDiscoveryParam() {
         connectionStringValidSet.forEach(connectionAddress -> {
             discoveryParamValidSet.forEach(discoveryParam -> {
                 String connectionString = connectionAddress + paramSectionDivider + discoveryParam;
@@ -298,55 +290,55 @@ public class OpcuaPlcDriverTest {
         builder.addItem("UInteger", UINTEGER_IDENTIFIER_READ_WRITE + ";UDINT", 102020202L);
 
 
-        builder.addItem("BooleanArray", BOOL_ARRAY_IDENTIFIER, new Boolean[] {true, true, true, true, true});
-        builder.addItem("ByteArray", BYTE_ARRAY_IDENTIFIER + ";BYTE", new Short[] {1, 100, 100, 255, 123});
-        builder.addItem("DoubleArray", DOUBLE_ARRAY_IDENTIFIER, new Double[] {1.0,2.0,3.0,4.0,5.0});
-        builder.addItem("FloatArray", FLOAT_ARRAY_IDENTIFIER, new Float[] {1.0F,2.0F,3.0F,4.0F,5.0F});
-        builder.addItem("Int16Array", INT16_ARRAY_IDENTIFIER, new Short[] {1,2,3,4,5});
-        builder.addItem("Int32Array", INT32_ARRAY_IDENTIFIER, new Integer[] {1,2,3,4,5});
-        builder.addItem("Int64Array", INT64_ARRAY_IDENTIFIER, new Long[] {1L,2L,3L,4L,5L});
-        builder.addItem("IntegerArray", INT32_ARRAY_IDENTIFIER, new Integer[] {1,2,3,4,5});
-        builder.addItem("SByteArray", SBYTE_ARRAY_IDENTIFIER, new Byte[] {1,2,3,4,5});
-        builder.addItem("StringArray", STRING_ARRAY_IDENTIFIER, new String[] {"1","2","3","4","5"});
-        builder.addItem("UInt16Array", UINT16_ARRAY_IDENTIFIER + ";UINT", new Short[] {1,2,3,4,5});
-        builder.addItem("UInt32Array", UINT32_ARRAY_IDENTIFIER + ";UDINT", new Integer[] {1,2,3,4,5});
-        builder.addItem("UInt64Array", UINT64_ARRAY_IDENTIFIER + ";ULINT", new Long[] {1L,2L,3L,4L,5L});
+        builder.addItem("BooleanArray", BOOL_ARRAY_IDENTIFIER, new Boolean[]{true, true, true, true, true});
+        builder.addItem("ByteArray", BYTE_ARRAY_IDENTIFIER + ";BYTE", new Short[]{1, 100, 100, 255, 123});
+        builder.addItem("DoubleArray", DOUBLE_ARRAY_IDENTIFIER, new Double[]{1.0, 2.0, 3.0, 4.0, 5.0});
+        builder.addItem("FloatArray", FLOAT_ARRAY_IDENTIFIER, new Float[]{1.0F, 2.0F, 3.0F, 4.0F, 5.0F});
+        builder.addItem("Int16Array", INT16_ARRAY_IDENTIFIER, new Short[]{1, 2, 3, 4, 5});
+        builder.addItem("Int32Array", INT32_ARRAY_IDENTIFIER, new Integer[]{1, 2, 3, 4, 5});
+        builder.addItem("Int64Array", INT64_ARRAY_IDENTIFIER, new Long[]{1L, 2L, 3L, 4L, 5L});
+        builder.addItem("IntegerArray", INT32_ARRAY_IDENTIFIER, new Integer[]{1, 2, 3, 4, 5});
+        builder.addItem("SByteArray", SBYTE_ARRAY_IDENTIFIER, new Byte[]{1, 2, 3, 4, 5});
+        builder.addItem("StringArray", STRING_ARRAY_IDENTIFIER, new String[]{"1", "2", "3", "4", "5"});
+        builder.addItem("UInt16Array", UINT16_ARRAY_IDENTIFIER + ";UINT", new Short[]{1, 2, 3, 4, 5});
+        builder.addItem("UInt32Array", UINT32_ARRAY_IDENTIFIER + ";UDINT", new Integer[]{1, 2, 3, 4, 5});
+        builder.addItem("UInt64Array", UINT64_ARRAY_IDENTIFIER + ";ULINT", new Long[]{1L, 2L, 3L, 4L, 5L});
 
         builder.addItem("DoesNotExists", DOES_NOT_EXIST_IDENTIFIER_READ_WRITE, "11");
 
         PlcWriteRequest request = builder.build();
         PlcWriteResponse response = request.execute().get();
 
-       assertThat(response.getResponseCode("Bool")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("Byte")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("Double")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("Float")).isEqualTo(PlcResponseCode.OK);
-       //assertThat(response.getResponseCode("Int16")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("Int32")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("Int64")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("Integer")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("SByte")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("String")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("UInt16")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("UInt32")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("UInt64")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("UInteger")).isEqualTo(PlcResponseCode.OK);
-
-       assertThat(response.getResponseCode("BooleanArray")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("ByteArray")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("DoubleArray")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("FloatArray")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("Int16Array")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("Int32Array")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("Int64Array")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("IntegerArray")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("SByteArray")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("StringArray")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("UInt16Array")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("UInt32Array")).isEqualTo(PlcResponseCode.OK);
-       assertThat(response.getResponseCode("UInt64Array")).isEqualTo(PlcResponseCode.OK);
-
-       assertThat(response.getResponseCode("DoesNotExists")).isEqualTo(PlcResponseCode.NOT_FOUND);
+        assertThat(response.getResponseCode("Bool")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("Byte")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("Double")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("Float")).isEqualTo(PlcResponseCode.OK);
+        //assertThat(response.getResponseCode("Int16")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("Int32")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("Int64")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("Integer")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("SByte")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("String")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("UInt16")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("UInt32")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("UInt64")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("UInteger")).isEqualTo(PlcResponseCode.OK);
+
+        assertThat(response.getResponseCode("BooleanArray")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("ByteArray")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("DoubleArray")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("FloatArray")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("Int16Array")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("Int32Array")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("Int64Array")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("IntegerArray")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("SByteArray")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("StringArray")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("UInt16Array")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("UInt32Array")).isEqualTo(PlcResponseCode.OK);
+        assertThat(response.getResponseCode("UInt64Array")).isEqualTo(PlcResponseCode.OK);
+
+        assertThat(response.getResponseCode("DoesNotExists")).isEqualTo(PlcResponseCode.NOT_FOUND);
 
         opcuaConnection.close();
         assert !opcuaConnection.isConnected();
@@ -399,7 +391,7 @@ public class OpcuaPlcDriverTest {
                     read_builder.addItem("Bool", BOOL_IDENTIFIER_READ_WRITE);
                     PlcReadRequest read_request = read_builder.build();
 
-                    for (int i = 0; i < 100; i ++) {
+                    for (int i = 0; i < 100; i++) {
                         PlcReadResponse read_response = read_request.execute().get();
                         assertThat(read_response.getResponseCode("Bool")).isEqualTo(PlcResponseCode.OK);
                     }
@@ -427,7 +419,7 @@ public class OpcuaPlcDriverTest {
                     write_builder.addItem("Bool", BOOL_IDENTIFIER_READ_WRITE, true);
                     PlcWriteRequest write_request = write_builder.build();
 
-                    for (int i = 0; i < 100; i ++) {
+                    for (int i = 0; i < 100; i++) {
                         PlcWriteResponse write_response = write_request.execute().get();
                         assertThat(write_response.getResponseCode("Bool")).isEqualTo(PlcResponseCode.OK);
                     }
diff --git a/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/protocol/ProfinetProtocolLogic.java b/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/protocol/ProfinetProtocolLogic.java
index e8424785b..62b209c10 100644
--- a/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/protocol/ProfinetProtocolLogic.java
+++ b/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/protocol/ProfinetProtocolLogic.java
@@ -66,7 +66,7 @@ public class ProfinetProtocolLogic extends Plc4xProtocolBase<Ethernet_Frame> {
     @Override
     public void onConnect(ConversationContext<Ethernet_Frame> context) {
         final Channel channel = context.getChannel();
-        if(!(channel instanceof RawSocketChannel)) {
+        if (!(channel instanceof RawSocketChannel)) {
             logger.warn("Expected a 'raw' transport, closing channel...");
             context.getChannel().close();
             return;
@@ -116,7 +116,7 @@ public class ProfinetProtocolLogic extends Plc4xProtocolBase<Ethernet_Frame> {
         // Generate a new session key.
         profinetDriverContext.setSessionKey(sessionKeyGenerator.getAndIncrement());
         // Reset the session key as soon as it reaches the max for a 16 bit uint
-        if(sessionKeyGenerator.get() == 0xFFFF) {
+        if (sessionKeyGenerator.get() == 0xFFFF) {
             sessionKeyGenerator.set(1);
         }
 
@@ -141,7 +141,7 @@ public class ProfinetProtocolLogic extends Plc4xProtocolBase<Ethernet_Frame> {
             udpSocket.receive(connectResponsePacket);
             ReadBufferByteBased readBuffer = new ReadBufferByteBased(resultBuffer);
             final DceRpc_Packet dceRpc_packet = DceRpc_Packet.staticParse(readBuffer);
-            if((dceRpc_packet.getOperation() == DceRpc_Operation.CONNECT) && (dceRpc_packet.getPacketType() == DceRpc_PacketType.RESPONSE)) {
+            if ((dceRpc_packet.getOperation() == DceRpc_Operation.CONNECT) && (dceRpc_packet.getPacketType() == DceRpc_PacketType.RESPONSE)) {
                 if (dceRpc_packet.getPayload().getPacketType() == DceRpc_PacketType.RESPONSE) {
                     // Get the remote MAC address and store it in the context.
                     final PnIoCm_Packet_Res connectResponse = (PnIoCm_Packet_Res) dceRpc_packet.getPayload();
@@ -162,14 +162,8 @@ public class ProfinetProtocolLogic extends Plc4xProtocolBase<Ethernet_Frame> {
             } else {
                 throw new PlcException("Unexpected response");
             }
-        } catch (SerializationException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (PlcException e) {
-            e.printStackTrace();
-        } catch (ParseException e) {
-            e.printStackTrace();
+        } catch (SerializationException | IOException | PlcException | ParseException e) {
+            logger.error("Error", e);
         }
 
         //System.out.println(rawSocketChannel);
@@ -200,7 +194,6 @@ public class ProfinetProtocolLogic extends Plc4xProtocolBase<Ethernet_Frame> {
     }
 
 
-
     private Optional<PcapNetworkInterface> getNetworkInterfaceForConnection(InetAddress address) {
         try {
             for (PcapNetworkInterface dev : Pcaps.findAllDevs()) {
@@ -228,7 +221,7 @@ public class ProfinetProtocolLogic extends Plc4xProtocolBase<Ethernet_Frame> {
                 new DceRpc_InterfaceUuid_DeviceInterface(),
                 profinetDriverContext.getDceRpcActivityUuid(),
                 0, 0, DceRpc_Operation.CONNECT,
-                new PnIoCm_Packet_Req(404, 404, 404,0, 404,
+                new PnIoCm_Packet_Req(404, 404, 404, 0, 404,
                     Arrays.asList(
                         new PnIoCm_Block_ArReq((short) 1, (short) 0, PnIoCm_ArType.IO_CONTROLLER,
                             new Uuid(Hex.decodeHex("654519352df3b6428f874371217c2b51")),
diff --git a/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/netty/utils/ArpUtils.java b/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/netty/utils/ArpUtils.java
index b93a444a9..0fd66ca80 100644
--- a/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/netty/utils/ArpUtils.java
+++ b/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/netty/utils/ArpUtils.java
@@ -47,11 +47,11 @@ public class ArpUtils {
         // Check if libpcap is available.
         try {
             String libVersion = Pcaps.libVersion();
-            if(libVersion.startsWith("libpcap version ")) {
+            if (libVersion.startsWith("libpcap version ")) {
                 libVersion = libVersion.substring(16);
                 // If we're on MacOS we need to check if we're at least at version 1.10.1 as the default bundled with
                 // the os has issues.
-                if(SystemUtils.IS_OS_MAC) {
+                if (SystemUtils.IS_OS_MAC) {
                     if (!checkVersionAtLeast(libVersion, "1.10.1")) {
                         logger.warn("On MacOS libpcap 1.10.1 is required, this system uses libpcap " + libVersion + ". " +
                             "When using libpcap from homebrew, make sure to have added the library path. " +
@@ -68,11 +68,11 @@ public class ArpUtils {
         }
 
         Set<InetAddress> foundAddresses = new HashSet<>();
-        try{
+        try {
             // Calculate all ip addresses, this device can reach.
             Map<String, List<String>> addresses = new HashMap<>();
             for (PcapAddress address : nif.getAddresses()) {
-                if(address instanceof PcapIpV4Address) {
+                if (address instanceof PcapIpV4Address) {
                     final PcapIpV4Address ipV4Address = (PcapIpV4Address) address;
                     SubnetUtils su = new SubnetUtils(ipV4Address.getAddress().getHostAddress(), ipV4Address.getNetmask().getHostAddress());
                     final String currentAddress = ipV4Address.getAddress().getHostAddress();
@@ -83,7 +83,7 @@ public class ArpUtils {
                 }
             }
             // If this device doesn't have any addresses, abort.
-            if(addresses.isEmpty()) {
+            if (addresses.isEmpty()) {
                 return Collections.emptySet();
             }
 
@@ -92,7 +92,7 @@ public class ArpUtils {
                 .map(linkLayerAddress -> (MacAddress) linkLayerAddress).findFirst();
             // If we couldn't find a local mac address, abort.
             //noinspection SimplifyOptionalCallChains (Not compatible with Java 8)
-            if(!first.isPresent()) {
+            if (!first.isPresent()) {
                 return Collections.emptySet();
             }
             final MacAddress localMacAddress = first.get();
@@ -110,7 +110,7 @@ public class ArpUtils {
                 sb.append(" and ether dst ").append(Pcaps.toBpfString(localMacAddress)).append(" and (");
                 boolean firstAddress = true;
                 for (String localAddress : addresses.keySet()) {
-                    if(!firstAddress) {
+                    if (!firstAddress) {
                         sb.append(" or ");
                     }
                     sb.append("(dst host ").append(localAddress).append(")");
@@ -138,7 +138,7 @@ public class ArpUtils {
                     try {
                         while (receivingHandle.isOpen()) {
                             final Packet nextPacket = receivingHandle.getNextPacket();
-                            if(nextPacket != null) {
+                            if (nextPacket != null) {
                                 listener.gotPacket(nextPacket);
                             }
                         }
@@ -184,7 +184,7 @@ public class ArpUtils {
                     Thread.currentThread().interrupt();
                 }
             } catch (UnknownHostException e) {
-                e.printStackTrace();
+                logger.error("error", e);
             } finally {
                 // Gracefully shut down.
                 if (receivingHandle.isOpen()) {