Ewan Higgs created THRIFT-4932:
----------------------------------
Summary: Using a default empty 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.12.0, 0.9.3
Reporter: Ewan Higgs
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)