BJ-141: TBase handler reuse (#33)

This commit is contained in:
Pavel Popov 2017-03-21 12:32:08 +03:00 committed by GitHub
parent 847a2e3e69
commit 49974bdbd3
2 changed files with 15 additions and 1 deletions

View File

@ -334,7 +334,19 @@ public class TBaseHandler<R extends TBase> implements StructHandler<R> {
@Override
public R getResult() throws IOException {
return result;
if (result == null) {
throw new BadFormatException("result is null");
}
if (!(stateStack.isEmpty()
&& fieldStack.isEmpty()
&& elementStack.isEmpty()
&& valueMetaDataStack.isEmpty())) {
throw new BadFormatException("stack is not empty");
}
R tBase = result;
result = null;
return tBase;
}
}

View File

@ -217,6 +217,8 @@ public class TBaseHandlerTest {
handler.endStruct();
handler.endStruct();
handler.getResult();
}