Yes, it looks like collect doesn't like null values. Granted, I'm not
sure your patch does the right thing as it will filter out the
complete mapping - we'll have to see if that is what we want in all
places (probably but we need to double check). Can you create issues
for this please?

regards,

Karl

On Thu, Sep 7, 2017 at 9:33 PM, Nicolas Peltier
<[email protected]> wrote:
> so [1] fixes it.
>
> i see it as well in
>
> org.apache.sling.launchpad.webapp.integrationtest.util.JsonUtil
> org.apache.sling.distribution.it.JsonUtil
>
> guess fixing it there won't hurt
>
> [1] diff --git 
> a/contrib/extensions/sling-pipes/src/main/java/org/apache/sling/pipes/internal/JsonUtil.java
> b/contrib/extensions/sling-pipes/src/main/java/org/apache/sling/pipes/internal/JsonUtil.java
> index 2d669a843c..1f557bf7d6 100644
> --- 
> a/contrib/extensions/sling-pipes/src/main/java/org/apache/sling/pipes/internal/JsonUtil.java
> +++ 
> b/contrib/extensions/sling-pipes/src/main/java/org/apache/sling/pipes/internal/JsonUtil.java
> @@ -80,6 +80,7 @@ public class JsonUtil {
>                  :
>                  ((JsonObject) json).entrySet().stream()
>                      .map(entry -> new
> AbstractMap.SimpleEntry<>(entry.getKey(),unbox(entry.getValue())))
> +                    .filter(entry -> entry.getValue() != null)
>                      .collect(Collectors.toMap(Entry::getKey,
> Entry::getValue)));
>      }
>
> 2017-09-07 19:54 GMT+02:00 Nicolas Peltier <[email protected]>:
>> Hey Karl,
>>
>> have some weird NPE [0] in sling pipes' JsonUtil when "unboxing" null
>> values, but lambda make it hard to debug really :-/
>>
>> i'm happy to fix it, but should i just create & fix a pipes bug in
>> that project, i saw several static unbox in sling project?
>>
>> is there a plan to have one more central JsonUtil.unbox ?
>>
>> Nicolas
>>
>> [0] @Test
>> public void unbox() throws Exception {
>>     JsonArray array = (JsonArray)
>> JsonUtil.parse("[{\"foo\":\"foo\",\"bar\":null}]");
>>     Object binding = JsonUtil.unbox(array.get(0));
>> }
>>
>>
>> java.lang.NullPointerException
>>     at java.util.HashMap.merge(HashMap.java:1224)
>>     at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)
>>     at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
>>     at 
>> java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
>>     at 
>> java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet.lambda$entryConsumer$0(Collections.java:1575)
>>     at java.util.Iterator.forEachRemaining(Iterator.java:116)
>>     at 
>> java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>>     at 
>> java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet$UnmodifiableEntrySetSpliterator.forEachRemaining(Collections.java:1600)
>>     at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
>>     at 
>> java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
>>     at 
>> java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
>>     at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>>     at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
>>     at 
>> org.apache.sling.pipes.internal.JsonUtil.lambda$unbox$1(JsonUtil.java:83)
>>     at org.apache.sling.pipes.internal.JsonUtil.unbox(JsonUtil.java:57)
>>     at org.apache.sling.pipes.internal.JsonUtil.unbox(JsonUtil.java:76)
>>     at 
>> org.apache.sling.pipes.internal.JsonUtilTest.unbox(JsonUtilTest.java:17)



-- 
Karl Pauls
[email protected]

Reply via email to