走thrift tutorial得例子:
发现一个问题,在client发送 (1 DIVIDE 0):{
work.op = Operation.DIVIDE;
work.num1 = 1;
work.num2 = 0;
} 这种请求得时候,server本来应该返回InvalidOperation异常,client捕获。但是Server确实返回了,但是client并没有得到异常,而是success。
跟踪代码,发现server确实write 了异常到struct中,但是client read得时候,也read成功,不过在Calculator.java得2523行得“struct.setSuccessIsSet(true);”这行代码执行后,read返回得结果会根据isSuccessIsSet来返回结果,所以因此虽然server返回了异常InvalidOperation,但是因为isSuccessIsSet=true,所以client得“int quotient = client.calculate(1, work);” 不会抛出异常,直接返回success得默认值0.
见代码:
public void read(org.apache.thrift.protocol.TProtocol iprot, calculate_result struct) throws org.apache.thrift.TException {
System.out.println("calculate_resultStandardScheme read start!!!!!!!!");
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 0: // SUCCESS
System.out.println("calculate_resultStandardScheme read SUCCESS!!!!!!!!");
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.success = iprot.readI32();
// struct.setSuccessIsSet(true); // 这里默认是没有注释得。我注释了,异常就正常抛出了。
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 1: // OUCH
System.out.println("calculate_resultStandardScheme read OUCH!!!!!!!!");
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.ouch = new InvalidOperation();
struct.ouch.read(iprot);
struct.setOuchIsSet(true);
System.out.println("calculate_resultStandardScheme read OUCH111111");
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
System.out.println("calculate_resultStandardScheme struct:" + struct);
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
分享到:
相关推荐
http://chanian.com/2010/05/13/thrift-tutorial-a-php-client/ 原教程使用的是c++ server和php client. 我用c++和c#分别实现了client和server,他们之间可以用任意组合互相调用,没有太复杂的功能,非常利于初学...
maven-thrift-plugin-0.1.11-sources.jar
NULL 博文链接:https://hanqunfeng.iteye.com/blog/1947627
cassandra-thrift cassandra-thrift cassandra-thrift cassandra-thrift cassandra-thrift cassandra-thrift
thrift文件生成工具thrift-0.9.1.exe和thrift-0.9.2.exe压缩包
maven-thrift-plugin-0.1.11.jar
Java中的yii2-thrift客户端测试 用法 要运行,请先安装Maven mvn install 然后启动应用程序 然后跑 java -jar target/yii2-thrift-test-client-java-1.0-SNAPSHOT-jar-with-dependencies.jar
NULL 博文链接:https://onlyor.iteye.com/blog/1700777
thrift 0.9.3 for vs2013/vs2015 直接打开 thrift-master-0.9.3\lib\cppVS2013\thrift.sln thrift-master-0.9.3\lib\cppVS2015\thrift.sln 编译即可
thrift开发时,将thrift文件自动生成java文件需要用到thrift-0.9.0.exe
thrift-0.13.0在Windows上exe程序;thrift-0.13.0在Windows上exe程序;thrift-0.13.0在Windows上exe程序
thrift-0.13.0 已编译的Java版本 包含thrift和其依赖包 thrift-0.13.0 已编译的Java版本 包含thrift和其依赖包
thrift-client 最简单测试案例
thrift开发时,将thrift文件自动生成java文件需要用到thrift-0.9.0.exe
spark-hive-thriftserver_2.11-2.1.spark-hive-thrift
NULL 博文链接:https://hanqunfeng.iteye.com/blog/1936556
导入Maven依赖与junit一起工作 < dependency> < groupId>com.didiglobal.thriftmock</ groupId> < artifactId>thrift-mock-server4junit</ artifactId> < version>1.0.2</ version> </ dependency> 在...
thrift开发时,将thrift文件自动生成java文件需要用到thrift-0.9.3.exe
thrift 示例项目,server端基于Java实现,client端基于Nodejs实现,与台州微信银行保持一样的通讯方式RPC: 远程过程调用,需要解决的问题: 通讯,序列化等项目结构thriftshared.thrift, tutorial.thrift 为thrift...