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 2019/12/18 23:08:21 UTC

[plc4x] branch next-gen-core updated: potential fix for mixed lists

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

sruehl pushed a commit to branch next-gen-core
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/next-gen-core by this push:
     new f9c67e3  potential fix for mixed lists
f9c67e3 is described below

commit f9c67e37b70a4d2da962c43a5a344f76aed5eed1
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Dec 19 00:07:58 2019 +0100

    potential fix for mixed lists
---
 .../src/main/java/org/apache/plc4x/java/api/value/PlcList.java | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcList.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcList.java
index 378170e..3f065c8 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcList.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcList.java
@@ -28,7 +28,15 @@ public class PlcList extends PlcValueAdapter {
     private final List<PlcValue> listItems;
 
     PlcList(List<PlcValue> listItems) {
-        this.listItems = Collections.unmodifiableList(listItems);
+        List<PlcValue> safelist = listItems.stream().map(plcValue -> {
+            // to avoid unwrapped list cause of type erasure
+            if (plcValue instanceof PlcValue) {
+                return plcValue;
+            } else {
+                return PlcValues.of(plcValue);
+            }
+        }).collect(Collectors.toList());
+        this.listItems = Collections.unmodifiableList(safelist);
     }
 
     @Override