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 2018/01/12 11:14:37 UTC

[incubator-plc4x] branch master updated (5886538 -> e3a7d29)

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

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


    from 5886538  fixed timing issues on get responseItem by signaling after item has been set not before.
     new 36d151f  Put the await into a while loop to handle "spurious wakeup"
     new 80b2ba5  no need to wrap PlcException in RuntimeException as camel allows Producer constructors to throw exceptions
     new 8940cb4  log expection on connection close failure
     new 37afedb  transport the inner exception in PlcConnectionException
     new 5dd6ab5  use parseInt instead of valueOf
     new e3a7d29  use specific exceptions

The 6 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:
 .../java/org/apache/plc4x/camel/PLC4XProducer.java | 13 +++++--------
 .../plc4x/java/api/messages/items/RequestItem.java |  2 +-
 .../org/apache/plc4x/java/PlcDriverManager.java    |  2 +-
 .../apache/plc4x/java/s7/utils/PcapGenerator.java  | 22 ++++++++++++----------
 .../java/org/apache/plc4x/java/s7/S7PlcDriver.java |  4 ++--
 5 files changed, 21 insertions(+), 22 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@plc4x.apache.org" <co...@plc4x.apache.org>'].

[incubator-plc4x] 05/06: use parseInt instead of valueOf

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

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

commit 5dd6ab5892d83581393a847c21b5168d24f4efb6
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Jan 12 12:08:59 2018 +0100

    use parseInt instead of valueOf
---
 .../s7/src/main/java/org/apache/plc4x/java/s7/S7PlcDriver.java        | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/S7PlcDriver.java b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/S7PlcDriver.java
index 86127cc..9156f18 100644
--- a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/S7PlcDriver.java
+++ b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/S7PlcDriver.java
@@ -56,8 +56,8 @@ public class S7PlcDriver implements PlcDriver {
                 "Connection url doesn't match the format 's7://{host|ip}/{rack}/{slot}'");
         }
         String host = matcher.group("host");
-        int rack = Integer.valueOf(matcher.group("rack"));
-        int slot = Integer.valueOf(matcher.group("slot"));
+        int rack = Integer.parseInt(matcher.group("rack"));
+        int slot = Integer.parseInt(matcher.group("slot"));
         return new S7PlcConnection(host, rack, slot);
     }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@plc4x.apache.org" <co...@plc4x.apache.org>.

[incubator-plc4x] 01/06: Put the await into a while loop to handle "spurious wakeup"

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

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

commit 36d151f1ba686052e636123e17d3f60a300d63c0
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Jan 12 11:52:53 2018 +0100

    Put the await into a while loop to handle "spurious wakeup"
---
 .../main/java/org/apache/plc4x/java/api/messages/items/RequestItem.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/items/RequestItem.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/items/RequestItem.java
index 5932f91..fdad7f9 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/items/RequestItem.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/items/RequestItem.java
@@ -57,7 +57,7 @@ public abstract class RequestItem<DATA_TYPE, RESPONSE_ITEM extends ResponseItem>
             if (responseItem == null) {
                 try {
                     lock.lock();
-                    if (responseItem == null) {
+                    while (responseItem == null) {
                         responseSet.await();
                     }
                 } catch (InterruptedException e) {

-- 
To stop receiving notification emails like this one, please contact
"commits@plc4x.apache.org" <co...@plc4x.apache.org>.

[incubator-plc4x] 06/06: use specific exceptions

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

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

commit e3a7d29a9fecdba7bc11aead088b35f80c847e67
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Jan 12 12:13:13 2018 +0100

    use specific exceptions
---
 .../apache/plc4x/java/s7/utils/PcapGenerator.java  | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/plc4j/protocols/s7-utils/src/main/java/org/apache/plc4x/java/s7/utils/PcapGenerator.java b/plc4j/protocols/s7-utils/src/main/java/org/apache/plc4x/java/s7/utils/PcapGenerator.java
index b78ecc3..f8d811f 100644
--- a/plc4j/protocols/s7-utils/src/main/java/org/apache/plc4x/java/s7/utils/PcapGenerator.java
+++ b/plc4j/protocols/s7-utils/src/main/java/org/apache/plc4x/java/s7/utils/PcapGenerator.java
@@ -18,17 +18,18 @@ under the License.
 */
 package org.apache.plc4x.java.s7.utils;
 
+import org.apache.commons.io.FileExistsException;
 import org.apache.commons.io.FileUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.*;
 import java.io.File;
+import java.io.IOException;
 import java.util.Arrays;
 
 /**
@@ -270,10 +271,11 @@ public class PcapGenerator {
         // Write Ack variable generation
     }
 
-    private static void generateFiles(File parentDir, String testName, int byteIndex, byte[] template, String matchXPath) throws Exception {
+    private static void generateFiles(File parentDir, String testName, int byteIndex, byte[] template, String matchXPath)
+        throws IOException, ParserConfigurationException, XPathExpressionException, InterruptedException, SAXException {
         File testDir = new File(parentDir, testName);
-        if(!testDir.exists() && !testDir.mkdirs()) {
-            throw new RuntimeException("Error creating directory " + testDir.getAbsolutePath());
+        if (!testDir.exists() && !testDir.mkdirs()) {
+            throw new FileExistsException("Error creating directory " + testDir.getAbsolutePath());
         }
 
         // Initialize the heavy weight XML stuff.
@@ -285,7 +287,7 @@ public class PcapGenerator {
         XPathExpression expr = xpath.compile(matchXPath);
 
         // Iterate over all possible value the current byte could have.
-        for(int i = 0; i <= 255; i++) {
+        for (int i = 0; i <= 255; i++) {
 
             // Generate a packet.
             byte[] copy = Arrays.copyOf(template, template.length);
@@ -302,10 +304,10 @@ public class PcapGenerator {
 
             // Check if a given XPath is found -> A valid parameter was found.
             Document document = builder.parse(decodedOutput);
-            NodeList list= (NodeList) expr.evaluate(document, XPathConstants.NODESET);
+            NodeList list = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
 
             // If a valid parameter is found, output that to the console.
-            if(list.getLength() > 0) {
+            if (list.getLength() > 0) {
                 String name = list.item(0).getAttributes().getNamedItem("showname").getNodeValue();
                 String value = list.item(0).getAttributes().getNamedItem("value").getNodeValue();
                 System.out.println("found option for " + testName + ": " + name + " = 0x" + value);

-- 
To stop receiving notification emails like this one, please contact
"commits@plc4x.apache.org" <co...@plc4x.apache.org>.

[incubator-plc4x] 04/06: transport the inner exception in PlcConnectionException

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

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

commit 37afedb2a0a339a6be4ac3e64f077e2213165dc2
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Jan 12 12:04:49 2018 +0100

    transport the inner exception in PlcConnectionException
---
 plc4j/core/src/main/java/org/apache/plc4x/java/PlcDriverManager.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plc4j/core/src/main/java/org/apache/plc4x/java/PlcDriverManager.java b/plc4j/core/src/main/java/org/apache/plc4x/java/PlcDriverManager.java
index d038913..8539a61 100644
--- a/plc4j/core/src/main/java/org/apache/plc4x/java/PlcDriverManager.java
+++ b/plc4j/core/src/main/java/org/apache/plc4x/java/PlcDriverManager.java
@@ -89,7 +89,7 @@ public class PlcDriverManager {
             }
             return driver;
         } catch (URISyntaxException e) {
-            throw new PlcConnectionException("Invalid plc4j connection string '" + url + "'");
+            throw new PlcConnectionException("Invalid plc4j connection string '" + url + "'", e);
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@plc4x.apache.org" <co...@plc4x.apache.org>.

[incubator-plc4x] 02/06: no need to wrap PlcException in RuntimeException as camel allows Producer constructors to throw exceptions

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

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

commit 80b2ba5fe713ecbb4932f31b4e2fd9564f39dea8
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Jan 12 12:01:02 2018 +0100

    no need to wrap PlcException in RuntimeException as camel allows
    Producer constructors to throw exceptions
---
 .../src/main/java/org/apache/plc4x/camel/PLC4XProducer.java    | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/PLC4XProducer.java b/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/PLC4XProducer.java
index 92a1b5b..af5df7e 100644
--- a/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/PLC4XProducer.java
+++ b/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/PLC4XProducer.java
@@ -40,15 +40,11 @@ public class PLC4XProducer extends DefaultAsyncProducer {
     private PlcConnection plcConnection;
     private AtomicInteger openRequests;
 
-    public PLC4XProducer(PLC4XEndpoint endpoint) {
+    public PLC4XProducer(PLC4XEndpoint endpoint) throws PlcException {
         super(endpoint);
         this.endpoint = endpoint;
-        try {
-            String plc4xURI = endpoint.getEndpointUri().replaceFirst("plc4x:/?/?", "");
-            plcConnection = endpoint.plcDriverManager.getConnection(plc4xURI);
-        } catch (PlcException e) {
-            throw new RuntimeException(e);
-        }
+        String plc4xURI = endpoint.getEndpointUri().replaceFirst("plc4x:/?/?", "");
+        plcConnection = endpoint.plcDriverManager.getConnection(plc4xURI);
         openRequests = new AtomicInteger();
     }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@plc4x.apache.org" <co...@plc4x.apache.org>.

[incubator-plc4x] 03/06: log expection on connection close failure

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

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

commit 8940cb455da3d1508759f424bf50d008a93742dc
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Jan 12 12:03:30 2018 +0100

    log expection on connection close failure
---
 .../src/main/java/org/apache/plc4x/camel/PLC4XProducer.java            | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/PLC4XProducer.java b/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/PLC4XProducer.java
index af5df7e..891de5b 100644
--- a/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/PLC4XProducer.java
+++ b/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/PLC4XProducer.java
@@ -107,7 +107,8 @@ public class PLC4XProducer extends DefaultAsyncProducer {
         }
         try {
             plcConnection.close();
-        } catch (Exception ignore) {
+        } catch (Exception e) {
+            log.warn("Could not close {}", plcConnection, e);
         }
         super.doStop();
     }

-- 
To stop receiving notification emails like this one, please contact
"commits@plc4x.apache.org" <co...@plc4x.apache.org>.