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 2018/02/10 19:19:51 UTC

[incubator-plc4x] branch feature/junit4 updated (d260f0d -> 2912001)

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

cdutz pushed a change to branch feature/junit4
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git.


    from d260f0d  PLC4X-3 - Implement a testing framework for protocols
     new c451106  Changed the build to only do the sonar analysis on develop (Otherwise the commits on branches overwrite the develop results)
     new 2912001  Fixed some sonar findings.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Jenkinsfile                                        |  4 ++--
 .../base/connection/TcpSocketChannelFactory.java   |  1 +
 .../plc4x/java/s7/netty/Plc4XS7Protocol.java       |  1 +
 .../plc4x/java/utils/rawsockets/RawSocket.java     | 28 +++++-----------------
 4 files changed, 10 insertions(+), 24 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
cdutz@apache.org.

[incubator-plc4x] 01/02: Changed the build to only do the sonar analysis on develop (Otherwise the commits on branches overwrite the develop results)

Posted by cd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch feature/junit4
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git

commit c4511064e9da17d2f03c321842255ca365ae960c
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Sat Feb 10 20:19:05 2018 +0100

    Changed the build to only do the sonar analysis on develop (Otherwise the commits on branches overwrite the develop results)
---
 Jenkinsfile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 2ecf0fc..986a2a7 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -34,7 +34,7 @@ node('ubuntu') {
     def mavenGoal = "install"
     def mavenLocalRepo = ""
     if(env.BRANCH_NAME == 'develop') {
-        mavenGoal = "deploy"
+        mavenGoal = "deploy sonar:sonar"
     } else {
         mavenLocalRepo = "-Dmaven.repo.local=.repository"
     }
@@ -52,7 +52,7 @@ node('ubuntu') {
 
         stage ('Build') {
             echo 'Building'
-            sh "${mvnHome}/bin/mvn -Pjenkins-build ${mavenLocalRepo} clean ${mavenGoal} sonar:sonar site:site"
+            sh "${mvnHome}/bin/mvn -Pjenkins-build ${mavenLocalRepo} clean ${mavenGoal} site:site"
         }
 
         stage ('Stage Site') {

-- 
To stop receiving notification emails like this one, please contact
cdutz@apache.org.

[incubator-plc4x] 02/02: Fixed some sonar findings.

Posted by cd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch feature/junit4
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git

commit 2912001bc4da67d5cc349356ff3cf61fa9ce4282
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Sat Feb 10 20:19:46 2018 +0100

    Fixed some sonar findings.
---
 .../base/connection/TcpSocketChannelFactory.java   |  1 +
 .../plc4x/java/s7/netty/Plc4XS7Protocol.java       |  1 +
 .../plc4x/java/utils/rawsockets/RawSocket.java     | 28 +++++-----------------
 3 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/plc4j/protocols/driver-base/src/main/java/org/apache/plc4x/java/base/connection/TcpSocketChannelFactory.java b/plc4j/protocols/driver-base/src/main/java/org/apache/plc4x/java/base/connection/TcpSocketChannelFactory.java
index 514e3df..8cb8d08 100644
--- a/plc4j/protocols/driver-base/src/main/java/org/apache/plc4x/java/base/connection/TcpSocketChannelFactory.java
+++ b/plc4j/protocols/driver-base/src/main/java/org/apache/plc4x/java/base/connection/TcpSocketChannelFactory.java
@@ -55,6 +55,7 @@ public class TcpSocketChannelFactory implements ChannelFactory {
             // Wait till the session is finished initializing.
             return f.channel();
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new PlcConnectionException("Error creating channel.", e);
         }
     }
diff --git a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java
index 69a5745..24f269b 100644
--- a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java
+++ b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/Plc4XS7Protocol.java
@@ -339,6 +339,7 @@ public class Plc4XS7Protocol extends MessageToMessageCodec<S7Message, PlcRequest
         } else if (valueType == Integer.class) {
             result = encodeInteger(values, length);
         } else if (valueType == Calendar.class) {
+            // TODO: Decide what to do here ...
             result = null;
         } else if (valueType == Float.class) {
             result = encodeFloat(values, length);
diff --git a/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/RawSocket.java b/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/RawSocket.java
index 6b51ab6..098008a 100644
--- a/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/RawSocket.java
+++ b/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/RawSocket.java
@@ -102,9 +102,8 @@ public class RawSocket {
     }
 
     public void write(byte[] rawData) throws RawSocketException {
-        PcapHandle sendHandle = null;
-        try {
-            sendHandle = nif.openLive(SNAPLEN, PcapNetworkInterface.PromiscuousMode.PROMISCUOUS, READ_TIMEOUT);
+        try(PcapHandle sendHandle =
+                nif.openLive(SNAPLEN, PcapNetworkInterface.PromiscuousMode.PROMISCUOUS, READ_TIMEOUT)) {
             UnknownPacket.Builder packetBuilder = new UnknownPacket.Builder();
             packetBuilder.rawData(rawData);
 
@@ -139,10 +138,6 @@ public class RawSocket {
             sendHandle.sendPacket(p);
         } catch (PcapNativeException | NotOpenException e) {
             throw new RawSocketException("Error sending packet.", e);
-        } finally {
-            if((sendHandle != null) && sendHandle.isOpen()) {
-                sendHandle.close();
-            }
         }
     }
 
@@ -164,11 +159,10 @@ public class RawSocket {
     }
 
     protected MacAddress lookupMacAddress(InetAddress remoteIpAddress) throws RawSocketException {
-        try {
-            PcapHandle receiveHandle
-                = nif.openLive(SNAPLEN, PcapNetworkInterface.PromiscuousMode.PROMISCUOUS, READ_TIMEOUT);
-            PcapHandle sendHandle
-                = nif.openLive(SNAPLEN, PcapNetworkInterface.PromiscuousMode.PROMISCUOUS, READ_TIMEOUT);
+        try (PcapHandle receiveHandle
+                 = nif.openLive(SNAPLEN, PcapNetworkInterface.PromiscuousMode.PROMISCUOUS, READ_TIMEOUT);
+             PcapHandle sendHandle
+                 = nif.openLive(SNAPLEN, PcapNetworkInterface.PromiscuousMode.PROMISCUOUS, READ_TIMEOUT)){
 
             // Setup the filter to accept only the arp packets sent back to the current
             // host from the address of the remote host we wanted to get the mac address
@@ -228,16 +222,6 @@ public class RawSocket {
             }
         } catch (PcapNativeException | InterruptedException | ExecutionException | NotOpenException e) {
             throw new RawSocketException("Error looking up mac address.", e);
-        } finally {
-            /*if (receiveHandle.isOpen()) {
-                receiveHandle.close();
-            }
-            if (sendHandle.isOpen()) {
-                sendHandle.close();
-            }
-            if (!pool.isShutdown()) {
-                pool.shutdownNow();
-            }*/
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
cdutz@apache.org.