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

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


The following commit(s) were added to refs/heads/master by this push:
     new 7fd2259  Throw exception when retrieving non-existing Field in 
response.
     new 8f687de  Merge branch 'master' of 
https://gitbox.apache.org/repos/asf/incubator-plc4x
7fd2259 is described below

commit 7fd2259975f33e2090e9ebc3bf726c89b3beb2bb
Author: julian <j.feina...@pragmaticminds.de>
AuthorDate: Thu Nov 1 12:37:01 2018 +0100

    Throw exception when retrieving non-existing Field in response.
---
 .../org/apache/plc4x/java/base/messages/DefaultPlcReadResponse.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/base/messages/DefaultPlcReadResponse.java
 
b/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/base/messages/DefaultPlcReadResponse.java
index 30f80de..65c51ca 100644
--- 
a/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/base/messages/DefaultPlcReadResponse.java
+++ 
b/plc4j/protocols/driver-bases/base/src/main/java/org/apache/plc4x/java/base/messages/DefaultPlcReadResponse.java
@@ -19,6 +19,7 @@ under the License.
 package org.apache.plc4x.java.base.messages;
 
 import org.apache.commons.lang3.tuple.Pair;
+import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
 import org.apache.plc4x.java.api.model.PlcField;
 import org.apache.plc4x.java.api.types.PlcResponseCode;
 import org.apache.plc4x.java.base.messages.items.BaseDefaultFieldItem;
@@ -699,10 +700,10 @@ public class DefaultPlcReadResponse implements 
InternalPlcReadResponse {
     private BaseDefaultFieldItem getFieldInternal(String name) {
         // If this field doesn't exist, ignore it.
         if (values.get(name) == null) {
-            return null;
+            throw new PlcRuntimeException("No field with name '" + name + "' 
present in the response");
         }
         if (values.get(name).getKey() != PlcResponseCode.OK) {
-            return null;
+            throw new PlcRuntimeException("Field '" + name + "' could not be 
fetched, response was " + values.get(name).getKey());
         }
         return values.get(name).getValue();
     }

Reply via email to