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 2021/10/25 10:44:41 UTC

[plc4x] branch feature/mspec-ng updated: fix(plc4j/codgen): fixed data reader complex working with a empty logical name

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

sruehl pushed a commit to branch feature/mspec-ng
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/feature/mspec-ng by this push:
     new 2ebc8a6  fix(plc4j/codgen): fixed data reader complex working with a empty logical name
2ebc8a6 is described below

commit 2ebc8a609de7dc8e2d1d19cefea38ce305435298
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon Oct 25 12:44:30 2021 +0200

    fix(plc4j/codgen): fixed data reader complex working with a empty logical name
---
 .../plc4x/java/spi/codegen/io/DataReaderComplexDefault.java      | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderComplexDefault.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderComplexDefault.java
index ee60319..cce0239 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderComplexDefault.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderComplexDefault.java
@@ -18,6 +18,7 @@
  */
 package org.apache.plc4x.java.spi.codegen.io;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.plc4x.java.spi.generation.ByteOrder;
 import org.apache.plc4x.java.spi.generation.ParseException;
 import org.apache.plc4x.java.spi.generation.ReadBuffer;
@@ -63,9 +64,13 @@ public class DataReaderComplexDefault<T> implements DataReaderComplex<T> {
     }
 
     public T read(String logicalName, ComplexTypeSupplier<T> complexSupplier, WithReaderArgs... readerArgs) throws ParseException {
-        readBuffer.pullContext(logicalName,readerArgs);
+        // TODO: it might be even better if we default to value like in other places... on the other hand a complex type has always a proper logical name so this might be fine like that
+        boolean hasLogicalName = StringUtils.isNotBlank(logicalName);
+        if (hasLogicalName)
+            readBuffer.pullContext(logicalName, readerArgs);
         final T t = complexSupplier.get();
-        readBuffer.closeContext(logicalName,readerArgs);
+        if (hasLogicalName)
+            readBuffer.closeContext(logicalName, readerArgs);
         return t;
     }