[ 
https://issues.apache.org/jira/browse/FLINK-8423?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16361156#comment-16361156
 ] 

ASF GitHub Bot commented on FLINK-8423:
---------------------------------------

Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5447#discussion_r167633643
  
    --- Diff: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/OperatorChain.java
 ---
    @@ -591,16 +591,28 @@ public void collect(StreamRecord<T> record) {
                                operator.setKeyContextElement1(copy);
                                operator.processElement(copy);
                        } catch (ClassCastException e) {
    -                           // Enrich error message
    -                           ClassCastException replace = new 
ClassCastException(
    -                                   String.format(
    -                                           "%s. Failed to push OutputTag 
with id '%s' to operator. " +
    -                                           "This can occur when multiple 
OutputTags with different types " +
    -                                           "but identical names are being 
used.",
    -                                           e.getMessage(),
    -                                           outputTag.getId()));
    -
    -                           throw new 
ExceptionInChainedOperatorException(replace);
    +                           ClassCastException replace;
    +                           if (outputTag != null) {
    +                                   // Enrich error message
    +                                   replace = new ClassCastException(
    +                                           String.format(
    +                                                   "%s. Failed to push 
OutputTag with id '%s' to operator. " +
    +                                                           "This can occur 
when multiple OutputTags with different types " +
    +                                                           "but identical 
names are being used.",
    +                                                   e.getMessage(),
    +                                                   outputTag.getId()));
    +
    +                                   throw new 
ExceptionInChainedOperatorException(replace);
    +                           } else {
    +                                   replace = new ClassCastException(
    +                                           String.format(
    +                                                   "%s. Failed to push 
OutputTag with id '%s' to operator. " +
    --- End diff --
    
    Please properly read my comments. Jut replace the else block with `throw e`.
    
    If the OutputTag is null there's no point in modifying the error message.


> OperatorChain#pushToOperator catch block may fail with NPE
> ----------------------------------------------------------
>
>                 Key: FLINK-8423
>                 URL: https://issues.apache.org/jira/browse/FLINK-8423
>             Project: Flink
>          Issue Type: Bug
>          Components: Streaming
>    Affects Versions: 1.4.0, 1.5.0
>            Reporter: Chesnay Schepler
>            Assignee: mingleizhang
>            Priority: Critical
>
> {code}
> @Override
> protected <X> void pushToOperator(StreamRecord<X> record) {
>       try {
>               // we know that the given outputTag matches our OutputTag so 
> the record
>               // must be of the type that our operator (and Serializer) 
> expects.
>               @SuppressWarnings("unchecked")
>               StreamRecord<T> castRecord = (StreamRecord<T>) record;
>               numRecordsIn.inc();
>               StreamRecord<T> copy = 
> castRecord.copy(serializer.copy(castRecord.getValue()));
>               operator.setKeyContextElement1(copy);
>               operator.processElement(copy);
>       } catch (ClassCastException e) {
>               // Enrich error message
>               ClassCastException replace = new ClassCastException(
>                       String.format(
>                               "%s. Failed to push OutputTag with id '%s' to 
> operator. " +
>                               "This can occur when multiple OutputTags with 
> different types " +
>                               "but identical names are being used.",
>                               e.getMessage(),
>                               outputTag.getId()));
>               throw new ExceptionInChainedOperatorException(replace);
>       } catch (Exception e) {
>               throw new ExceptionInChainedOperatorException(e);
>       }
> }
> {code}
> If outputTag is null (as is the case when no sideOutput was defined) the 
> catch block will crash with a NullPointerException. This may happen if 
> {{operator.processElement}} throws a ClassCastException.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to