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 dff0d4180a590a84898a7337d04322a649b5e19f
Author: Sebastian Rühl <sru...@apache.org>
AuthorDate: Wed Jun 13 14:17:23 2018 +0200

    set interrupt flag where necessary.
---
 .../ads/adslib/ADSClientNotificationExample.java   |  1 +
 .../org/apache/plc4x/java/ads/adslib/AdsLib.java   | 30 ++++++++++++++++++----
 .../apache/plc4x/java/ads/adslib/AmsRouter.java    | 18 ++++++++++---
 3 files changed, 41 insertions(+), 8 deletions(-)

diff --git 
a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/ADSClientNotificationExample.java
 
b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/ADSClientNotificationExample.java
index 126d011..67bf68c 100644
--- 
a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/ADSClientNotificationExample.java
+++ 
b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/ADSClientNotificationExample.java
@@ -264,6 +264,7 @@ public class ADSClientNotificationExample {
                 TimeUnit.SECONDS.sleep(timeout);
                 System.out.println("Timeout reached enter pressed");
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 throw new RuntimeException(e);
             }
         }
diff --git 
a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AdsLib.java
 
b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AdsLib.java
index 0aff88e..08a31da 100644
--- 
a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AdsLib.java
+++ 
b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AdsLib.java
@@ -163,8 +163,12 @@ public class AdsLib {
             buffer.value = bytes;
             bytesRead.value = bytes.length;
             return response.getResult();
-        } catch (InterruptedException | ExecutionException | TimeoutException 
e) {
+        } catch (ExecutionException | TimeoutException e) {
+            e.printStackTrace();
+            return Result.of(AdsReturnCode.ADS_CODE_1);
+        } catch (InterruptedException e) {
             e.printStackTrace();
+            Thread.currentThread().interrupt();
             return Result.of(AdsReturnCode.ADS_CODE_1);
         }
     }
@@ -239,9 +243,13 @@ public class AdsLib {
             adsState.value = response.getAdsState().getAsInt();
             devState.value = response.getDeviceState().getAsInt();
             return response.getResult();
-        } catch (InterruptedException | ExecutionException | TimeoutException 
e) {
+        } catch (ExecutionException | TimeoutException e) {
             e.printStackTrace();
             return Result.of(AdsReturnCode.ADS_CODE_1);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+            Thread.currentThread().interrupt();
+            return Result.of(AdsReturnCode.ADS_CODE_1);
         }
     }
 
@@ -341,9 +349,13 @@ public class AdsLib {
         try {
             AdsWriteResponse response = request.getResponseFuture().get(3, 
TimeUnit.SECONDS);
             return response.getResult();
-        } catch (InterruptedException | ExecutionException | TimeoutException 
e) {
+        } catch (ExecutionException | TimeoutException e) {
             e.printStackTrace();
             return Result.of(AdsReturnCode.ADS_CODE_1);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+            Thread.currentThread().interrupt();
+            return Result.of(AdsReturnCode.ADS_CODE_1);
         }
     }
 
@@ -443,8 +455,12 @@ public class AdsLib {
         try {
             AdsAddDeviceNotificationResponse response = 
request.getResponseFuture().get(3, TimeUnit.SECONDS);
             return response.getResult();
-        } catch (InterruptedException | ExecutionException | TimeoutException 
e) {
+        } catch (ExecutionException | TimeoutException e) {
+            e.printStackTrace();
+            return Result.of(AdsReturnCode.ADS_CODE_1);
+        } catch (InterruptedException e) {
             e.printStackTrace();
+            Thread.currentThread().interrupt();
             return Result.of(AdsReturnCode.ADS_CODE_1);
         }
     }
@@ -479,8 +495,12 @@ public class AdsLib {
         try {
             AdsDeleteDeviceNotificationResponse response = 
request.getResponseFuture().get(3, TimeUnit.SECONDS);
             return response.getResult();
-        } catch (InterruptedException | ExecutionException | TimeoutException 
e) {
+        } catch (ExecutionException | TimeoutException e) {
+            e.printStackTrace();
+            return Result.of(AdsReturnCode.ADS_CODE_1);
+        } catch (InterruptedException e) {
             e.printStackTrace();
+            Thread.currentThread().interrupt();
             return Result.of(AdsReturnCode.ADS_CODE_1);
         }
     }
diff --git 
a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRouter.java
 
b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRouter.java
index 5e1d768..ba0bf79 100644
--- 
a/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRouter.java
+++ 
b/plc4j/protocols/ads/src/test/java/org/apache/plc4x/java/ads/adslib/AmsRouter.java
@@ -203,9 +203,13 @@ public class AmsRouter {
             PlcProprietaryResponse<R> response = completableFuture.get(3, 
TimeUnit.SECONDS);
             request.getResponseFuture().complete(response.getResponse());
             return response.getResponse().getAmsHeader().getCode();
-        } catch (InterruptedException | ExecutionException | TimeoutException 
e) {
+        } catch (ExecutionException | TimeoutException e) {
             e.printStackTrace();
             return AmsError.of(AdsReturnCode.ADS_CODE_1864);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+            Thread.currentThread().interrupt();
+            return AmsError.of(AdsReturnCode.ADS_CODE_1864);
         }
     }
 
@@ -231,8 +235,12 @@ public class AmsRouter {
             port.AddNotification(pNotification.value, notify);
             request.getResponseFuture().complete(response.getResponse());
             return response.getResponse().getAmsHeader().getCode();
-        } catch (InterruptedException | ExecutionException | TimeoutException 
e) {
+        } catch (ExecutionException | TimeoutException e) {
+            e.printStackTrace();
+            return AmsError.of(AdsReturnCode.ADS_CODE_1);
+        } catch (InterruptedException e) {
             e.printStackTrace();
+            Thread.currentThread().interrupt();
             return AmsError.of(AdsReturnCode.ADS_CODE_1);
         }
     }
@@ -253,8 +261,12 @@ public class AmsRouter {
             adsLibPort.DelNotification(pAddr, 
plcProprietaryRequest.getRequest().getNotificationHandle());
             request.getResponseFuture().complete(response.getResponse());
             return response.getResponse().getAmsHeader().getCode();
-        } catch (InterruptedException | ExecutionException | TimeoutException 
e) {
+        } catch (ExecutionException | TimeoutException e) {
+            e.printStackTrace();
+            return AmsError.of(AdsReturnCode.ADS_CODE_1);
+        }catch (InterruptedException e) {
             e.printStackTrace();
+            Thread.currentThread().interrupt();
             return AmsError.of(AdsReturnCode.ADS_CODE_1);
         }
     }

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

Reply via email to