Return-Path: X-Original-To: apmail-flink-issues-archive@minotaur.apache.org Delivered-To: apmail-flink-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 412AB17442 for ; Sun, 9 Aug 2015 12:33:46 +0000 (UTC) Received: (qmail 19786 invoked by uid 500); 9 Aug 2015 12:33:46 -0000 Delivered-To: apmail-flink-issues-archive@flink.apache.org Received: (qmail 19742 invoked by uid 500); 9 Aug 2015 12:33:46 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 19729 invoked by uid 99); 9 Aug 2015 12:33:46 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Aug 2015 12:33:46 +0000 Date: Sun, 9 Aug 2015 12:33:45 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FLINK-2495) Add a null point check in API DataStream.union MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FLINK-2495?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14679126#comment-14679126 ] ASF GitHub Bot commented on FLINK-2495: --------------------------------------- Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/999#discussion_r36587360 --- Diff: flink-staging/flink-streaming/flink-streaming-core/src/main/java/org/apache/flink/streaming/api/datastream/DataStream.java --- @@ -256,9 +256,11 @@ public ExecutionConfig getExecutionConfig() { DataStream returnStream = this.copy(); for (DataStream stream : streams) { - for (DataStream ds : stream.unionedStreams) { - validateUnion(ds.getId()); - returnStream.unionedStreams.add(ds.copy()); + if (stream != null) { --- End diff -- Right there will be an error, but the error is helpful because it indicates a problem with the user program. If the union is silently ignored, the program might behave differently from what the user expects and produce invalid results. I would argue, that a `union(null)` is never intended and should be be brought to the user's attention. Also, this error might reveal more problems of the user program. > Add a null point check in API DataStream.union > ---------------------------------------------- > > Key: FLINK-2495 > URL: https://issues.apache.org/jira/browse/FLINK-2495 > Project: Flink > Issue Type: Bug > Components: Streaming > Affects Versions: 0.10 > Reporter: Huang Wei > Fix For: 0.10 > > Original Estimate: 168h > Remaining Estimate: 168h > > The API(public DataStream union(DataStream... streams)) is a external interface for user. > The parameter "streams" maybe null and it will throw NullPointerException error. > This test below can be intuitive to explain this problem: > package org.apache.flink.streaming.api; > import org.apache.flink.api.common.functions.MapFunction; > import org.apache.flink.streaming.api.datastream.DataStream; > import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; > import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction; > import org.junit.Test; > /** > * Created by HuangWHWHW on 2015/8/7. > */ > public class test { > public static class sourceFunction extends RichParallelSourceFunction { > public sourceFunction() { > } > @Override > public void run(SourceContext sourceContext) throws Exception { > sourceContext.collect("a"); > } > @Override > public void cancel() { > } > } > @Test > public void testUnion(){ > StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); > env.setParallelism(1); > DataStream source = env.addSource(new sourceFunction()); > DataStream temp1 = null; > DataStream temp2 = source.map(new MapFunction() { > @Override > public String map(String value) throws Exception { > if (value == "a") { > return "This is for test temp2."; > } > return null; > } > }); > DataStream sink = temp2.union(temp1); > sink.print(); > try { > env.execute(); > }catch (Exception e){ > e.printStackTrace(); > } > } > } -- This message was sent by Atlassian JIRA (v6.3.4#6332)