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

cdutz 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 981928d  Made the Java part compatible with Java 1.8 again
981928d is described below

commit 981928d18f72d4c3a53bba4894e5b99585042865
Author: cdutz <[email protected]>
AuthorDate: Tue Sep 21 11:25:48 2021 +0200

    Made the Java part compatible with Java 1.8 again
---
 .../org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java   | 14 +++++++++++++-
 .../org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java | 17 +++++++++++++++--
 .../opcua/protocol/OpcuaSubscriptionHandleTest.java     |  7 ++++++-
 3 files changed, 34 insertions(+), 4 deletions(-)

diff --git 
a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java
 
b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java
index ec9f2c7..12bd102 100644
--- 
a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java
+++ 
b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java
@@ -37,6 +37,9 @@ import 
org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField;
 import org.eclipse.milo.examples.server.ExampleServer;
 
 import java.math.BigInteger;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.time.Duration;
 import java.time.temporal.ChronoUnit;
 import java.util.Collections;
@@ -91,9 +94,18 @@ public class ManualPLC4XOpcua {
 
     public static void main(String args[]) {
         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 testServer = new ExampleServer();
             testServer.startup().get();
-
         } catch (Exception e) {
             throw new PlcRuntimeException(e);
         }
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 e5c3bbe..9b48f0b 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
@@ -39,6 +39,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.math.BigInteger;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 
 /**
  */
@@ -118,10 +121,20 @@ public class OpcuaPlcDriverTest {
     @BeforeAll
     public static void setup() {
         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();
         } catch (Exception e) {
-
+            e.printStackTrace();
         }
     }
 
@@ -130,7 +143,7 @@ public class OpcuaPlcDriverTest {
         try {
             exampleServer.shutdown().get();
         } catch (Exception e) {
-
+            e.printStackTrace();
         }
     }
 
diff --git 
a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java
 
b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java
index f465e21..51aad06 100644
--- 
a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java
+++ 
b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java
@@ -32,6 +32,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.nio.file.Files;
+import java.nio.file.LinkOption;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
@@ -88,7 +89,11 @@ public class OpcuaSubscriptionHandleTest {
             // 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");
-            Files.delete(securityBaseDir);
+            try {
+                Files.delete(securityBaseDir);
+            } catch (Exception e) {
+                // Ignore this ...
+            }
 
             exampleServer = new ExampleServer();
             exampleServer.startup().get();

Reply via email to