beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Groh (JIRA)" <>
Subject [jira] [Commented] (BEAM-2123) Passing potential null pointer to encode() in StructuredCoder#structuralValue
Date Mon, 01 May 2017 15:59:04 GMT


Thomas Groh commented on BEAM-2123:

{{null}} is a valid value if the coder supports encoding null values. If not, the coder will
or should throw an appropriate exception, but we cannot know if the coder does or does not
support null values from within the {{StructuredCoder}} base class.

For ease of use elsewhere in the SDK, {{structuralValue}} does not throw {{IOExceptions}},
as it should always be possible for a Coder to encode to an in-memory byte array given valid

> Passing potential null pointer to encode() in StructuredCoder#structuralValue
> -----------------------------------------------------------------------------
>                 Key: BEAM-2123
>                 URL:
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-core
>            Reporter: Ted Yu
>            Assignee: Thomas Groh
>            Priority: Minor
>             Fix For: Not applicable
> {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

View raw message