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

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

commit b9f6c57b46c951be1a25a572938fb305a6c36e12
Author: Sebastian Rühl <sru...@apache.org>
AuthorDate: Thu May 24 13:03:39 2018 +0200

    null terminate ads-Data string
---
 .../org/apache/plc4x/java/ads/api/commands/types/Data.java    | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git 
a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
 
b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
index 98c75e3..89e528f 100644
--- 
a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
+++ 
b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
@@ -22,6 +22,7 @@ import io.netty.buffer.ByteBuf;
 import org.apache.plc4x.java.ads.api.util.ByteValue;
 
 import java.nio.charset.Charset;
+import java.util.Arrays;
 
 import static java.util.Objects.requireNonNull;
 
@@ -45,12 +46,18 @@ public class Data extends ByteValue {
 
     public static Data of(String value) {
         requireNonNull(value);
-        return new Data(value.getBytes());
+        byte[] origData = value.getBytes();
+        byte[] newData = Arrays.copyOf(origData, origData.length + 1);
+        newData[newData.length - 1] = 0x0;
+        return new Data(newData);
     }
 
     public static Data of(String value, Charset charset) {
         requireNonNull(value);
-        return new Data(value.getBytes(charset));
+        byte[] origData = value.getBytes(charset);
+        byte[] newData = Arrays.copyOf(origData, origData.length + 1);
+        newData[newData.length - 1] = 0x0;
+        return new Data(newData);
     }
 
     @Override

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

Reply via email to