You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by "Daniel Halperin (JIRA)" <ji...@apache.org> on 2017/04/30 17:37:04 UTC
[jira] [Commented] (BEAM-2123) Passing potential null pointer to
encode() in StructuredCoder#structuralValue
[ https://issues.apache.org/jira/browse/BEAM-2123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15990311#comment-15990311 ]
Daniel Halperin commented on BEAM-2123:
---------------------------------------
It looks like you believe `null` is not a valid value for any structured coder. Is that actually true? I don't believe so.
It's up to the extending coder to throw on `null` values.
> 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)