thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhangbo <>
Subject Exception "InvalidOperation" does not work in thrift(version 0.8) tutorial by java
Date Sat, 24 Dec 2011 08:02:31 GMT
Hi, everyone. I have a confusion. I build the tutorial of thrift (version 0.8) by java, input
commands according to README:
	1, thrift/tutorial$ thrift -r -gen java tutorial.thrift
	2, thrift/tutorial/java$ ant
	3, thrift/tutorial/java$ ./JavaServer
	4, thrift/tutorial/java$ ./JavaClient

		Starting the simple server...
		Starting the secure server...
		calculate(1, {DIVIDE,1,0})
		Whoa we can divide by 0
		Check log: 5

When server execute "1 DIVIDE 0", I found "InvalidOperation" has been thrown in ""
	InvalidOperation io = new InvalidOperation();
        io.what = work.op.getValue();
        io.why = "Cannot divide by 0";
        throw io;

But, it does not work. Server ( returns struct, which contains exception (InvalidOperation)
back to client, but when client execute "int quotient = client.calculate(1, work);", the exception
(InvalidOperation) has lost. Client code:
    try {
      int quotient = client.calculate(1, work);
      System.out.println("result is:" + quotient);
      System.out.println("Whoa we can divide by 0");
    } catch (InvalidOperation io) {
      System.out.println("Invalid operation: " + io.why);    // would not be execute, but
it should be when 1 DIVIDE 0

So, I follow the code automatically generated by thrift with tutorial.thrift. I found the
line "struct.setSuccessIsSet(true);" (line 2523 in is the reason. If the
line is be executed, client would receive success against exception (InvalidOperation).

Could anybody tell me why thrift do this?

Thanks a lot.

Bob Zhang


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message