Permalink
Browse files

[split] scrooge: writeFieldStop during transfer

RB_ID=268347
  • Loading branch information...
sprsquish authored and CI committed Jan 17, 2014
1 parent 5750978 commit 5f13a6a24cfecec5b6d7909b047b4c0aeb9e8f55
@@ -42,10 +42,11 @@ object ThriftUtil {
var done = false
while (!done) {
val field = inProt.readFieldBegin()
- outProt.writeFieldBegin(field)
if (field.`type` == TType.STOP) {
+ outProt.writeFieldStop()
done = true
} else {
+ outProt.writeFieldBegin(field)
transfer(outProt, inProt, field.`type`, maxDepth - 1)
inProt.readFieldEnd()
outProt.writeFieldEnd()
@@ -855,7 +855,7 @@ class ScalaGeneratorSpec extends JMockSpec with EvalHelper {
"pass through fields" should {
"pass through" in { _ =>
- val pt2 = PassThrough2(1, 2)
+ val pt2 = PassThrough2(1, PassThroughStruct(), PassThroughStruct())
val pt1 = {
val protocol = new TBinaryProtocol(new TMemoryBuffer(256))
@@ -873,7 +873,7 @@ class ScalaGeneratorSpec extends JMockSpec with EvalHelper {
}
"be copied" in { _ =>
- val pt2 = PassThrough2(1, 2)
+ val pt2 = PassThrough2(1, PassThroughStruct(), PassThroughStruct())
val pt1 = {
val protocol = new TBinaryProtocol(new TMemoryBuffer(256))
@@ -889,11 +889,11 @@ class ScalaGeneratorSpec extends JMockSpec with EvalHelper {
PassThrough2.decode(protocol)
}
- pt2roundTripped must be(PassThrough2(2, 2))
+ pt2roundTripped must be(PassThrough2(2, PassThroughStruct(), PassThroughStruct()))
}
"be removable" in { _ =>
- val pt2 = PassThrough2(1, 2)
+ val pt2 = PassThrough2(1, PassThroughStruct(), PassThroughStruct())
val pt1 = {
val protocol = new TBinaryProtocol(new TMemoryBuffer(256))
@@ -909,12 +909,12 @@ class ScalaGeneratorSpec extends JMockSpec with EvalHelper {
PassThrough2.decode(protocol)
}
- pt2roundTripped must be(PassThrough2(1, 0))
+ pt2roundTripped must be(PassThrough2(1, null, PassThroughStruct()))
}
"be able to add more" in { _ =>
val pt1 = PassThrough(1)
- val pt2 = PassThrough2(1, 2)
+ val pt2 = PassThrough2(1, PassThroughStruct(), null)
val f2 = pt2.getFieldBlob(PassThrough2.F2Field.id).get
val pt1w = pt1.setField(f2)
@@ -928,7 +928,7 @@ class ScalaGeneratorSpec extends JMockSpec with EvalHelper {
}
"be proxy-able" in { _ =>
- val pt2 = PassThrough2(1, 2)
+ val pt2 = PassThrough2(1, PassThroughStruct(), PassThroughStruct())
val pt1 = {
val protocol = new TBinaryProtocol(new TMemoryBuffer(256))
@@ -950,7 +950,7 @@ class ScalaGeneratorSpec extends JMockSpec with EvalHelper {
}
"be equallable" in { _ =>
- val pt2 = PassThrough2(1, 2)
+ val pt2 = PassThrough2(1, PassThroughStruct(), PassThroughStruct())
val pt1a = {
val protocol = new TBinaryProtocol(new TMemoryBuffer(256))
@@ -1,17 +1,18 @@
namespace java thrift.test
+struct PassThroughStruct {
+ optional i32 f1
+ optional i32 f2
+}
+
struct PassThrough {
1: i32 f1
}
struct PassThrough2 {
1: i32 f1,
- 2: i32 f2
-}
-
-struct PassThrough3 {
- i32 f1
- i32 f2
+ 2: PassThroughStruct f2
+ 3: PassThroughStruct f3
}
// Ensure services properly compile

0 comments on commit 5f13a6a

Please sign in to comment.