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 2019/02/03 16:38:47 UTC

[incubator-plc4x] 01/02: - Fixed some sonarqube findings

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/incubator-plc4x.git

commit 54b9f9c0c86e190a053694228799f0c703df941d
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Sun Feb 3 17:05:47 2019 +0100

    - Fixed some sonarqube findings
---
 .../apache/plc4x/examples/robot/controllers/RobotController.java  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/examples/hello-webapp/service/src/main/java/org/apache/plc4x/examples/robot/controllers/RobotController.java b/examples/hello-webapp/service/src/main/java/org/apache/plc4x/examples/robot/controllers/RobotController.java
index 9fe5194..0ff47c3 100644
--- a/examples/hello-webapp/service/src/main/java/org/apache/plc4x/examples/robot/controllers/RobotController.java
+++ b/examples/hello-webapp/service/src/main/java/org/apache/plc4x/examples/robot/controllers/RobotController.java
@@ -23,6 +23,8 @@ import org.apache.plc4x.java.PlcDriverManager;
 import org.apache.plc4x.java.api.PlcConnection;
 import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
 import org.apache.plc4x.java.api.messages.PlcWriteRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -37,6 +39,8 @@ import java.util.concurrent.TimeoutException;
 @RequestMapping("api/robot")
 public class RobotController {
 
+    private static final Logger logger = LoggerFactory.getLogger(RobotController.class);
+
     private static byte MOTOR_RIGHT_BACKWARDS = 0x01;
     private static byte MOTOR_RIGHT_ON = 0x02;
     private static byte MOTOR_LEFT_BACKWARDS = 0x04;
@@ -57,7 +61,7 @@ public class RobotController {
 
     @RequestMapping("move")
     public boolean move(@RequestParam(value="direction", defaultValue="stop") String direction) {
-        System.out.println("Move in direction: " + direction);
+        logger.info("Move in direction: " + direction);
         byte state = 0;
         switch (direction) {
             case "forward-right":
@@ -90,7 +94,7 @@ public class RobotController {
             updateRequest.execute().get(2000, TimeUnit.MILLISECONDS);
             return true;
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
-            e.printStackTrace();
+            logger.error("Caught Exception:", e);
             return false;
         }
     }