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/10/26 20:35:21 UTC
[incubator-plc4x] 05/06: [plc4j-opm] rearrange exception blocks
(sonar issue :/)
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 33af28e7d0eac200ec2560cc730131b58f164ee0
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Oct 26 22:19:54 2018 +0200
[plc4j-opm] rearrange exception blocks (sonar issue :/)
---
.../apache/plc4x/java/opm/PlcEntityManager.java | 28 ++++++++++------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/plc4j/utils/opm/src/main/java/org/apache/plc4x/java/opm/PlcEntityManager.java b/plc4j/utils/opm/src/main/java/org/apache/plc4x/java/opm/PlcEntityManager.java
index 1678359..e2f8a43 100644
--- a/plc4j/utils/opm/src/main/java/org/apache/plc4x/java/opm/PlcEntityManager.java
+++ b/plc4j/utils/opm/src/main/java/org/apache/plc4x/java/opm/PlcEntityManager.java
@@ -100,7 +100,6 @@ public class PlcEntityManager {
String source = annotation.value();
try (PlcConnection connection = driverManager.getConnection(source)) {
-
if (!connection.getMetadata().canRead()) {
throw new OPMException("Unable to get Reader for connection with url '" + source + "'");
}
@@ -117,23 +116,11 @@ public class PlcEntityManager {
);
// Build the request
- PlcReadRequest request;
- try {
- request = requestBuilder.build();
- } catch (PlcInvalidFieldException e) {
- throw new OPMException("Unable to parse one field request", e);
- }
+ PlcReadRequest request = requestBuilder.build();
// Perform the request
- PlcReadResponse response;
- try {
- // TODO: make configurable.
- response = request.execute().get(1_000, TimeUnit.MILLISECONDS);
- } catch (InterruptedException | ExecutionException e) {
- throw new OPMException("Request fetching not able", e);
- } catch (TimeoutException e) {
- throw new OPMException("Timeout during fetching values", e);
- }
+ // TODO: make configurable.
+ PlcReadResponse response = request.execute().get(1_000, TimeUnit.MILLISECONDS);
// Construct the Object
T instance = clazz.getConstructor().newInstance();
@@ -144,6 +131,15 @@ public class PlcEntityManager {
setField(clazz, instance, response, targetFieldName, fieldName);
}
return instance;
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new OPMException("Unable to fetch request", e);
+ } catch (ExecutionException e) {
+ throw new OPMException("Unable to fetch request", e);
+ } catch (TimeoutException e) {
+ throw new OPMException("Timeout during fetching values", e);
+ } catch (PlcInvalidFieldException e) {
+ throw new OPMException("Unable to parse one field request", e);
} catch (PlcConnectionException e) {
throw new OPMException("Unable to get connection with url '" + source + "'", e);
} catch (Exception e) {