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

[plc4x] branch develop updated: Made the Java part compatible with Java 1.8 again

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

commit abc98d3b3ca1ee4fbb8b33add6cd27019a3818d9
Author: cdutz <ch...@c-ware.de>
AuthorDate: Tue Sep 21 11:15:30 2021 +0200

    Made the Java part compatible with Java 1.8 again
---
 README.md                                                  |  4 ++--
 .../java/opcua/protocol/OpcuaSubscriptionHandleTest.java   | 14 ++++++++++++--
 .../opcuaserver/configuration/PasswordConfiguration.java   |  3 ---
 pom.xml                                                    |  4 +++-
 4 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index f4400b6..bacc72b 100644
--- a/README.md
+++ b/README.md
@@ -73,7 +73,7 @@ the language of choice.
 
 ### Java
 
-NOTE: Currently the Java versions which supports building of all parts of Apache PLC4X is Java 11 or higher (lower versions can't build the CMake dependent parts, such as PLC4C and PLC4Cpp). However, if you only want to build the Java parts, Java or above is also ok. 
+NOTE: Currently the Java versions which supports building of all parts of Apache PLC4X is Java 11 or higher (lower versions can't build the CMake dependent parts, such as PLC4C and PLC4Cpp). However, if you only want to build the Java parts, Java 1.8 or above is ok. 
 
 See the PLC4J user guide on the website to start using PLC4X in your Java application:
 [https://plc4x.apache.org/users/getting-started/plc4j.html](https://plc4x.apache.org/users/getting-started/plc4j.html)
@@ -84,7 +84,7 @@ See the PLC4J user guide on the website to start using PLC4X in your Java applic
 
 Currently, the project is configured to require the following software when building only the Java parts:
 
-1. Java 1.8 JDK: For running Maven in general as well as compiling the Java modules `JAVA_HOME` configured to point to that.
+1. Java 1.8 JDK: For running Maven in general as well as compiling the Java modules `JAVA_HOME` configured to point to that. If you also want to build the `plc4c` and `plc4cpp` modules, you will need at least Java 11.
 2. libpcap/WinPcap for raw socket tests in Java or use of `passive-mode` drivers
 3. (Optional) [Graphviz](https://www.graphviz.org/) : For generating the graphs in the documentation
 4. Git (even when working on the source distribution)
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 d62f7b8..f465e21 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
@@ -31,6 +31,10 @@ import org.junit.jupiter.api.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
 /**
  */
 public class OpcuaSubscriptionHandleTest {
@@ -80,13 +84,19 @@ public class OpcuaSubscriptionHandleTest {
     @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");
+            Files.delete(securityBaseDir);
+
             exampleServer = new ExampleServer();
             exampleServer.startup().get();
             //Connect
             opcuaConnection = new PlcDriverManager().getConnection(tcpConnectionAddress);
             assert opcuaConnection.isConnected();
         } catch (Exception e) {
-
+            e.printStackTrace();
         }
     }
 
@@ -99,7 +109,7 @@ public class OpcuaSubscriptionHandleTest {
 
             exampleServer.shutdown().get();
         } catch (Exception e) {
-
+            e.printStackTrace();
         }
     }
 
diff --git a/plc4j/integrations/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/PasswordConfiguration.java b/plc4j/integrations/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/PasswordConfiguration.java
index 5794594..5b5c987 100644
--- a/plc4j/integrations/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/PasswordConfiguration.java
+++ b/plc4j/integrations/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/PasswordConfiguration.java
@@ -20,7 +20,6 @@ package org.apache.plc4x.java.opcuaserver.configuration;
 
 import org.eclipse.jetty.util.security.Password;
 
-import java.util.List;
 import java.util.HashMap;
 import java.util.Map;
 import java.io.File;
@@ -34,8 +33,6 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 
-import org.slf4j.LoggerFactory;
-
 public class PasswordConfiguration {
 
     @JsonIgnore
diff --git a/pom.xml b/pom.xml
index 4d1cff1..367eb40 100644
--- a/pom.xml
+++ b/pom.xml
@@ -145,7 +145,8 @@
     <jackson.version>2.12.5</jackson.version>
     <!-- When updating this to the latest version, we're getting errors in the opcua server tests -->
     <jaxb.version>2.3.3</jaxb.version>
-    <jetty-util.version>11.0.6</jetty-util.version>
+    <!-- Newer versions are only compatible with Java 11. It's currently only used for obfuscating a password in the OPC-UA Server anyway -->
+    <jetty-util.version>9.4.43.v20210629</jetty-util.version>
     <jna.version>5.8.0</jna.version>
     <joda-time.version>2.10.10</joda-time.version>
     <jserialcom.version>2.7.0</jserialcom.version>
@@ -793,6 +794,7 @@
             <exclude>**/go.sum</exclude>
 
             <!--exclude>plc4go/**</exclude-->
+            <exclude>content/**</exclude>
           </excludes>
         </configuration>
       </plugin>