You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Ewan Higgs (Jira)" <ji...@apache.org> on 2019/08/20 08:14:00 UTC

[jira] [Updated] (THRIFT-4932) Using a default string on a binary field results in invalid Java code.

     [ https://issues.apache.org/jira/browse/THRIFT-4932?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ewan Higgs updated THRIFT-4932:
-------------------------------
    Summary: Using a default string on a binary field results in invalid Java code.  (was: Using a default empty string on a binary field results in invalid Java code.)

> Using a default string on a binary field results in invalid Java code.
> ----------------------------------------------------------------------
>
>                 Key: THRIFT-4932
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4932
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Compiler
>    Affects Versions: 0.9.3, 0.12.0
>            Reporter: Ewan Higgs
>            Priority: Major
>
> Given the following service definition:
> {code}
> $ cat Service.thrift 
> service MyService {
>     string doWork(
>     1: string arg1;
>     2: binary arg2 = '';
>     3: binary arg3 = '';
>     );
> }
> {code}
> And the following compilation:
> {code}
> /usr/local/Cellar/thrift/0.12.0/bin/thrift -gen java Service.thrift
> {code}
> Results in code that does not compile. This is because we end up with code like the following:
> {code}    
>     public doWork_args() {
>       this.arg2 = "";
>       this.arg3 = "";
>     }        
> {code}
> In Java you cannot set a {{ByteBuffer}} to a {{String}} value.
> Users can run into this situation if they were generating C++ code before ({{binary}} and {{string}} both resolve to {{std::string}}) and then only later decide to use Java with existing files.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)