You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Koji Hisano (Created) (JIRA)" <ji...@apache.org> on 2011/12/21 09:37:30 UTC
[jira] [Created] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Not throw user defined exception when a defined method returns boolean result
-----------------------------------------------------------------------------
Key: THRIFT-1474
URL: https://issues.apache.org/jira/browse/THRIFT-1474
Project: Thrift
Issue Type: Bug
Components: Java - Compiler
Affects Versions: 0.8
Reporter: Koji Hisano
A boolean result method always returns result value and exception value when a user defined exception is thrown.
So, client handles the result as having a result value and ignore the exception.
Sample thrift definition:
bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
Current generated code in createAccount_resultStandardScheme class:
public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
oprot.writeBool(struct.success);
oprot.writeFieldEnd();
if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
struct.serviceException.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
Correct generated code (Maybe):
public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.isSetSuccess()) {
oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
oprot.writeBool(struct.success);
oprot.writeFieldEnd();
}
if (struct.isSetServiceException()) {
oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
struct.serviceException.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Bryan Duxbury (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13245684#comment-13245684 ]
Bryan Duxbury commented on THRIFT-1474:
---------------------------------------
Arvind - I would be a lot more eager to apply this patch if it had some unit tests in it. Also, it looks like you only fixed the standard scheme. Any reason not to apply the same fix to the Tuple scheme?
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
> Attachments: codegen.diff, primitive_result_fix.patch
>
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Comment Edited] (THRIFT-1474) Not throw user defined
exception when a defined method returns boolean result
Posted by "Adrian Muraru (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13417087#comment-13417087 ]
Adrian Muraru edited comment on THRIFT-1474 at 7/18/12 2:08 PM:
----------------------------------------------------------------
This worked in previous versions of thrift (not sure when it's been introduced), however what about inspecting the result.x exception before checking the return value in recv_* functions:
{code:title=t_java_generator.cc|borderStyle=solid}
t_struct* xs = (*f_iter)->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ <<
indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl <<
indent() << " throw result." << (*x_iter)->get_name() << ";" << endl <<
indent() << "}" << endl;
}
// Careful, only return _result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ <<
indent() << "if (result." << generate_isset_check("success") << ") {" << endl <<
indent() << " return result.success;" << endl <<
indent() << "}" << endl;
}
{code}
Currently all generators look for return.success first and then for result.x.
I'd suggest to have the exceptions treated with higher priority.
was (Author: amuraru):
This worked in previous versions of thrift (not sure when it's been introduced), however what about inspecting the result.x exception before checking the return value in recv_* functions:
{code:title=t_java_generator.cc|borderStyle=solid}
t_struct* xs = (*f_iter)->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ <<
indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl <<
indent() << " throw result." << (*x_iter)->get_name() << ";" << endl <<
indent() << "}" << endl;
}
// Careful, only return _result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ <<
indent() << "if (result." << generate_isset_check("success") << ") {" << endl <<
indent() << " return result.success;" << endl <<
indent() << "}" << endl;
}
{code}
Currently all generators look for return.success first and than for result.x.
I'd suggest to have the exceptions treated with higher priority.
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
> Attachments: codegen.diff, primitive_result_fix.patch
>
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Arvind Jayaprakash (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Arvind Jayaprakash updated THRIFT-1474:
---------------------------------------
Attachment: primitive_result_fix.patch
patched on branch 0.8.x
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
> Attachments: primitive_result_fix.patch
>
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Adrian Muraru (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13417087#comment-13417087 ]
Adrian Muraru commented on THRIFT-1474:
---------------------------------------
This worked in previous versions of thrift (not sure when it's been introduced), however what about inspecting the result.x exception before checking the return value in recv_* functions:
{code:title=t_java_generator.cc|borderStyle=solid}
t_struct* xs = (*f_iter)->get_xceptions();
const std::vector<t_field*>& xceptions = xs->get_members();
vector<t_field*>::const_iterator x_iter;
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
f_service_ <<
indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl <<
indent() << " throw result." << (*x_iter)->get_name() << ";" << endl <<
indent() << "}" << endl;
}
// Careful, only return _result if not a void function
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ <<
indent() << "if (result." << generate_isset_check("success") << ") {" << endl <<
indent() << " return result.success;" << endl <<
indent() << "}" << endl;
}
{code}
Currently all generators look for return.success first and than for result.x.
I'd suggest to have the exceptions treated with higher priority.
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
> Attachments: codegen.diff, primitive_result_fix.patch
>
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "John Vines (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13417659#comment-13417659 ]
John Vines commented on THRIFT-1474:
------------------------------------
Checked out the newest patch, and it looks like it resolves the issue, but personally I don't like how it does it. The fix is in the change to order of the recv_RPC, but I think the actual read/write for the object should be changed so that SUCCESS_FIELD_DESC & struct.success is never written. That way if it gets broken again, it should be caught quickly.
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
> Attachments: THRIFT-1474-read-exceptions-first.patch, codegen.diff, primitive_result_fix.patch
>
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Koji Hisano (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Koji Hisano updated THRIFT-1474:
--------------------------------
Description:
A boolean result method always returns result value and exception value when a user defined exception is thrown.
So, client handles the result as having a result value and ignore the exception.
{code:title=Sample thrift definition|borderStyle=solid}
bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
{code}
{code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
oprot.writeBool(struct.success);
oprot.writeFieldEnd();
if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
struct.serviceException.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
{code}
{code:title=Correct generated code (Maybe)|borderStyle=solid}
public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.isSetSuccess()) {
oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
oprot.writeBool(struct.success);
oprot.writeFieldEnd();
}
if (struct.isSetServiceException()) {
oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
struct.serviceException.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
{code}
was:
A boolean result method always returns result value and exception value when a user defined exception is thrown.
So, client handles the result as having a result value and ignore the exception.
Sample thrift definition:
bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
Current generated code in createAccount_resultStandardScheme class:
public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
oprot.writeBool(struct.success);
oprot.writeFieldEnd();
if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
struct.serviceException.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
Correct generated code (Maybe):
public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.isSetSuccess()) {
oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
oprot.writeBool(struct.success);
oprot.writeFieldEnd();
}
if (struct.isSetServiceException()) {
oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
struct.serviceException.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Arvind Jayaprakash (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Arvind Jayaprakash updated THRIFT-1474:
---------------------------------------
Attachment: codegen.diff
Difference in generated code before & after the patch
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
> Attachments: codegen.diff, primitive_result_fix.patch
>
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Adrian Muraru (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Adrian Muraru updated THRIFT-1474:
----------------------------------
Attachment: THRIFT-1474-read-exceptions-first.patch
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
> Attachments: THRIFT-1474-read-exceptions-first.patch, codegen.diff, primitive_result_fix.patch
>
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Arvind Jayaprakash (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13245556#comment-13245556 ]
Arvind Jayaprakash commented on THRIFT-1474:
--------------------------------------------
This problem potentially manifests itself when the return type is any primitive and not just a boolean.
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Arvind Jayaprakash (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Arvind Jayaprakash updated THRIFT-1474:
---------------------------------------
Attachment: (was: codegen.diff)
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
> Attachments: codegen.diff, primitive_result_fix.patch
>
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Adrian Muraru (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13417272#comment-13417272 ]
Adrian Muraru commented on THRIFT-1474:
---------------------------------------
Attached a patch with exceptions checked before return object in all generators
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
> Attachments: THRIFT-1474-read-exceptions-first.patch, codegen.diff, primitive_result_fix.patch
>
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Assigned] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Bryan Duxbury (Assigned) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bryan Duxbury reassigned THRIFT-1474:
-------------------------------------
Assignee: Bryan Duxbury
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Arvind Jayaprakash (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13265049#comment-13265049 ]
Arvind Jayaprakash commented on THRIFT-1474:
--------------------------------------------
Bryan, I wouldn't mind expect that the existing set of tests seem to break on the existing code. Having the isolate broken tests, add new ones that are supposed to work etc. etc. isn't a very joyful activity. FWIW, the default java lib as it exists on branch 0.8.x doesn't seem to be running the test cases as part of the default target.
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
> Attachments: codegen.diff, primitive_result_fix.patch
>
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Arvind Jayaprakash (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Arvind Jayaprakash updated THRIFT-1474:
---------------------------------------
Attachment: codegen.diff
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
> Attachments: codegen.diff, primitive_result_fix.patch
>
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (THRIFT-1474) Not throw user defined exception
when a defined method returns boolean result
Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13265174#comment-13265174 ]
Bryan Duxbury commented on THRIFT-1474:
---------------------------------------
TRUNK's thrift library is tested just fine. What errors are you seeing?
> Not throw user defined exception when a defined method returns boolean result
> -----------------------------------------------------------------------------
>
> Key: THRIFT-1474
> URL: https://issues.apache.org/jira/browse/THRIFT-1474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Compiler
> Affects Versions: 0.8
> Reporter: Koji Hisano
> Assignee: Bryan Duxbury
> Attachments: codegen.diff, primitive_result_fix.patch
>
>
> A boolean result method always returns result value and exception value when a user defined exception is thrown.
> So, client handles the result as having a result value and ignore the exception.
> {code:title=Sample thrift definition|borderStyle=solid}
> bool createAccount(1:string userName, 2:string password, 3:string mailAddress) throws (1: Exception.ServiceException serviceException);
> {code}
> {code:title=Current generated code in createAccount_resultStandardScheme class|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC); // <- Problem because the value existence is not checked
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> if (struct.serviceException != null) { // <- I think it is better to use #isSetServiceException
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
> {code:title=Correct generated code (Maybe)|borderStyle=solid}
> public void write(org.apache.thrift.protocol.TProtocol oprot, createAccount_result struct) throws org.apache.thrift.TException {
> struct.validate();
> oprot.writeStructBegin(STRUCT_DESC);
> if (struct.isSetSuccess()) {
> oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
> oprot.writeBool(struct.success);
> oprot.writeFieldEnd();
> }
> if (struct.isSetServiceException()) {
> oprot.writeFieldBegin(SERVICE_EXCEPTION_FIELD_DESC);
> struct.serviceException.write(oprot);
> oprot.writeFieldEnd();
> }
> oprot.writeFieldStop();
> oprot.writeStructEnd();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira