You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2020/11/19 08:19:34 UTC

[incubator-streampipes-extensions] branch dev updated: Remove try block from s7 adapter

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

zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git


The following commit(s) were added to refs/heads/dev by this push:
     new deb6ae2  Remove try block from s7 adapter
deb6ae2 is described below

commit deb6ae295198162ec2eb14734f5ccd967234a20c
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Thu Nov 19 09:09:23 2020 +0100

    Remove try block from s7 adapter
---
 .../connect/adapters/plc4x/s7/Plc4xS7Adapter.java           | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java
index da6ef8e..1b6d315 100644
--- a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java
+++ b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java
@@ -213,8 +213,8 @@ public class Plc4xS7Adapter extends PullAdapter {
     protected void pullData() {
 
         // Create PLC read request
-        try (PlcConnection plcConnection = this.driverManager.getConnection("s7://" + this.ip)) {
-
+        try  {
+            PlcConnection plcConnection = this.driverManager.getConnection("s7://" + this.ip)
             PlcReadRequest.Builder builder = plcConnection.readRequestBuilder();
             for (Map<String, String> node : this.nodes) {
                 builder.addItem(node.get(PLC_NODE_NAME), node.get(PLC_NODE_NAME) + ":" + node.get(PLC_NODE_TYPE).toUpperCase());
@@ -223,7 +223,6 @@ public class Plc4xS7Adapter extends PullAdapter {
 
             // Execute the request
             PlcReadResponse response = null;
-            try {
                 response = readRequest.execute().get();
 
                 // Create an event containing the value of the PLC
@@ -246,14 +245,10 @@ public class Plc4xS7Adapter extends PullAdapter {
                 LOG.error(e.getMessage());
                 e.printStackTrace();
             } catch (Exception e) {
+                System.out.println("Could not establish connection to S7 with ip " + this.ip);
+                this.LOG.error("Could not establish connection to S7 with ip " + this.ip, e);
                 e.printStackTrace();
             }
-        } catch (Exception e) {
-            System.out.println("Could not establish connection to S7 with ip " + this.ip);
-            this.LOG.error("Could not establish connection to S7 with ip " + this.ip, e);
-            e.printStackTrace();
-        }
-
 
     }