beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Halperin (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (BEAM-2123) Passing potential null pointer to encode() in StructuredCoder#structuralValue
Date Mon, 01 May 2017 00:26:04 GMT

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

Daniel Halperin commented on BEAM-2123:
---------------------------------------

https://github.com/apache/beam/blob/a198f8d232bda1ae68467b17027565d9fcef63a8/sdks/java/core/src/test/java/org/apache/beam/sdk/coders/StructuredCoderTest.java#L45

I typoed -- NullBooleanCoder not Nullable, but it should have been obvious what I meant.

> Passing potential null pointer to encode() in StructuredCoder#structuralValue
> -----------------------------------------------------------------------------
>
>                 Key: BEAM-2123
>                 URL: https://issues.apache.org/jira/browse/BEAM-2123
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-core
>            Reporter: Ted Yu
>            Assignee: Thomas Groh
>            Priority: Minor
>
> {code}
>   public Object structuralValue(T value) {
>     if (value != null && consistentWithEquals()) {
>       return value;
>     } else {
>       try {
>         ByteArrayOutputStream os = new ByteArrayOutputStream();
>         encode(value, os, Context.OUTER);
> {code}
> If value is null, encode() would throw CoderException (I checked ByteArrayCoder and KvCoder)
which would be caught and converted to IllegalArgumentException.
> Looks like structuralValue() can check null value directly and throw CoderException.
This would result in clearer exception.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message