From 696cf779d457c89184ea1d4aa18702f7cca63fd1 Mon Sep 17 00:00:00 2001 From: Yilun Chong Date: Wed, 28 Jun 2017 11:32:01 -0700 Subject: [PATCH] add java supported --- conformance/ConformanceJava$1.class | Bin 1535 -> 1535 bytes .../ConformanceJava$BinaryDecoder$1.class | Bin 863 -> 1241 bytes .../ConformanceJava$BinaryDecoder$2.class | Bin 1014 -> 1482 bytes .../ConformanceJava$BinaryDecoder$3.class | Bin 1644 -> 2256 bytes .../ConformanceJava$BinaryDecoder$4.class | Bin 1479 -> 2057 bytes .../ConformanceJava$BinaryDecoder$5.class | Bin 1650 -> 2270 bytes .../ConformanceJava$BinaryDecoder$6.class | Bin 1716 -> 2339 bytes .../ConformanceJava$BinaryDecoder$7.class | Bin 1310 -> 1860 bytes .../ConformanceJava$BinaryDecoder.class | Bin 2220 -> 2553 bytes conformance/ConformanceJava.class | Bin 7832 -> 9250 bytes conformance/ConformanceJava.java | 201 ++++++++++++++++-- 11 files changed, 184 insertions(+), 17 deletions(-) diff --git a/conformance/ConformanceJava$1.class b/conformance/ConformanceJava$1.class index 823d43744ad9afcc8341d50dd53c3e6d35105b8f..ab225e5710171dc5627e09f7b0315190053e4958 100644 GIT binary patch delta 18 acmey*{hxcobXGRTB@AYawUg(vCIJ9LX9iaQ delta 18 acmey*{hxcobXGQo{|sgfk0#G$O#%Q&g9jA= diff --git a/conformance/ConformanceJava$BinaryDecoder$1.class b/conformance/ConformanceJava$BinaryDecoder$1.class index 940e39f0dd7cec4f30816c636807c6afae2a71c5..b54414b4a12add35e2e812d3b94a6c6d8c73bc75 100644 GIT binary patch delta 501 zcma)3yG{a85IwWIaF^vNuJVu-R21ATOpt;ENg%N@(OB>SQmi&4kX;%pqov(uV`5?9 zCupUy@B{n>3k93n!VGJ7>T z9i$min37?igZ@Kw{H2m-RlO;dj0K(`VG+4-Qm}B6-Q?BdC?kOaf88qPIY(fiw5#!b LY+V)AAZOH1()Cy1 delta 265 zcmZ9FF;2rk5Jlgt?bzNV5FjBCV(hpJX^}ueNGZ4o1r-f~10Ye-McdMG0jNL}93VHK z%1sd8E*WWN|NMC~`;%`vllAY{H*iYriP`gbhAE?zgH?H%CwJHP4>u{3)$NNNg;zW8 zCKNr6=^JIJToE!iv@#T~wkj;$lg+|7dJdat^cd-26Hb}X!APYlxsl%NWHGf5>|NT( zR2u@$RCD^;YUn~;yTACvz5PQk*pd?q+1AN{v}1?e){B`#PqG%^Ii#zM8MA-o+y7Z+ JOf_ea{Q-478ovMl diff --git a/conformance/ConformanceJava$BinaryDecoder$2.class b/conformance/ConformanceJava$BinaryDecoder$2.class index 64553b6f4fcd446ebe6fe241730ac80528d0a651..1d3c0862b52673922e65ff91f699a643b8023f1a 100644 GIT binary patch delta 557 zcma)3OG`pQ6#i!J&9STHBdzRZnWm}b6AGj-Y9W#l{xy>U$>W! zWm6WRVwk3W^-Bo<)f6OWyMBR~z@`&%B%DZM%R07YndMnZc34PFGnC{5FUb$Kqh=UR zsEEeL93haE5&p)i@}4K7V~XTEKVt=J%>I802G3!me%WYU>-7txtl#M2OfiiKdRfa9 zasfLSCgr&j@M~1tr~;1Ybif5p$ej}C43QGtgsX&m$i47e9O|r6#VOhoPvFl`A1P-T w>MA2T1+#>5%we9QI@o5KvN&z#LBqiCa>gWe;JAhMzzQ7gLbKU=tT1ONa4 delta 287 zcmYLC%TB^j5Iu8gxtH6jAVnc3 z%EW~qzz4Y`OxZBW%$zxAX3pICm%)7T`v>40Ee#u4t6E>Bx-4VU9cy~^ld27 zNGBh(Z$9awoJS~e;3C4Iix^EpU^=2{P6(~E>zT{km$|YYo=W}k z=w&>8O-9edyW~BI&w5>0Y@CJQ%tL~p7=_H|xU2SQoqj;yj0uI+4spHVNn?|*lnHJB sajo29i*<|jB7Z0`7T894#br(#oDu5|>Tuz+dlmjbGsDqS2(n&OOF2^_{r~^~ diff --git a/conformance/ConformanceJava$BinaryDecoder$3.class b/conformance/ConformanceJava$BinaryDecoder$3.class index 104336d566d90afa0fcafd164e8aa2e004f6c01d..ad8bf31d73ae50864bf3b62ae65791d3a9a01c3d 100644 GIT binary patch delta 776 zcma))K~ED=6otPxo$@B*00oLzpa@#D6f0V)q6oH76c9>_g($iqI6;)qhIWA~_ijux ziCh1HiE&|~#Kf&De~9rXsCOzx6J2zYd*7XV&O7J5JM-1~(y{RQ`}>bTnsu9Y&f3Ho zu}LuMSLggHX>*=2n{F;>E^1Pmaf`H#%_W;5E^Dr6uGMo>?Z+yc`&GBFU#^wMHP`FU zUu6WE(oFx_sj%k`w%kf>r@U8H{6!bhjH0vTR%_Ya-O|&FTW!dsyd^VI|CElW#(Zqq ztyVX;e`B$K>66~9nn;G25nG2@a^meU$4!S@%sVWwsJZR1#Ii%46-CM`nqluyy|6+Q z{9e(^8)E#}MY!Kx>13Vxij0naL0Roy{O`oP8rHRVS2RJFPDbkk2 zAg7PyW2)8r5FCE?$7D+w55>e4lWoy@Bqlpz@>n#UG;b0hCWZ#XoM{;QljxC15R@Nw dlH(#Z#0|MwM5fezm5H29n-IuYWc@W{{RBjpj_Uvb delta 425 zcmXAk&rX^_6vcnTC(P&MLxkcVs8mF2t^ZN9SZj+4Do`yx0yQ+zL@;WMJ2&o)nYi{L z+_`Y)#+9#O;xnlCtCQR_=iYO2X6|G3*(*N0+};5>ej7T-7zPB^a}WN-z`f)z=q5@VAjTYTgXDQbLTn_h7w2)v5mXcC&F7F}ujWRa9u rpiQD(9QuU^NHg$%=6|SLDkFNFIl3gKgIQ*ZMji``QgB(2i%$0qPPjNP diff --git a/conformance/ConformanceJava$BinaryDecoder$4.class b/conformance/ConformanceJava$BinaryDecoder$4.class index 2bfeda922ce6af8be181642717840a6ca0d23ca7..16a4ce4e6019066f950001203037935185cf7954 100644 GIT binary patch delta 741 zcma)(O;1xn6o#LFk9(U7ZAv2A(_7FpEb zS4`YAcWdI#y)jYZ!mWw%Pw+>K=QbKm5W^&A&YU^#ndi*R*Wjy2?%R*gUw~;AEkc~K z80NG^oDqvCqna^ILX!-Tve2Y0`Z=Q+*JRo=bKSvOx$fA@^=hL!rOCFp-sZdlg|*mR zwQG%g)rzC|OO@43E21m5(}7 zFy}PqL(FnPlM9jOVu(2|xm)U8FwA8yC@6;9TgISUGGeOe-ZX~IdBqj?iJ5mZX1GhU zptvsK*!Th2nvx>fF2+9W8n2aVy5D`v2k-lVdBbg)iPpbhik^jPRKCv)|P;|@cBxYwPkV+4zPpJ2@r-;bhB_3)r_izNGqrU%3-IxA|v4hVY z^(St7;uG?#urA^aS*;7~k>Hww*_6V^9F?qvaaD6{Uen8QiA_=a#rhcB=lC5gH|ZZ~ z{UL0N{;3eQh44%W&xPUF%l&mZCIG8kavu?`-iE@x>uSSD^U3)QV diff --git a/conformance/ConformanceJava$BinaryDecoder$5.class b/conformance/ConformanceJava$BinaryDecoder$5.class index c5dea858554a0becfaf9a729f90925418319a39b..e6d0f7bbbb62d61519e17aa575c3f01a582f1f33 100644 GIT binary patch delta 801 zcma))O;1xn6o#LgjUvQ=P4aLBgS(&c|lY%q8L8~@M+pL z9h&_pO-!2K$pL{)p$^FG;*du#J8SNSze_c{+y0*Wo>0I1Bv_ZM4H0@JIh(ZcT8KA= z_l*d?6~TAH_r7sKA8{cy=%H7Qz@+Dc FfnPO{oVWl0 delta 453 zcmXAkIZs)c#fD zy%8qG;4#ItxIAW<^_U~)G0%c#(Id~2$1*F5LHiW0wSMS29AQ<_Y_m?%#+{g2vwcol zt=nzqQf=I2DqfT=hqrd3i>2aT>Ey^S?iSYlbH6Q{8=y)~3tmVfLJf+juoM+IlHE*q zqq;}^7Owaz7?unL!CJmcSKz*~|8&Y;==Pt1BaJJ#FL)r+52fpf1VtJsk)%u$$JC1> zPUuYpM-$g1wCGCHC`Ts6f-In9ghR9NkSx^lQ45x>lSqpmV}x%qrkWuJ^F}_a5+&y{ IA&DCI9nrfzeE!nJ!7^-hfmiJJ5!_r5#to_o%jH}k6LnRj;k$L1RV1GuTf zjgXEWgmpv^wX0scI%cPsjz0A3XhU4!xWItG2`5hKaN(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8l$u=PrYm3DliT!?oPLJ)a{>yomRUUo`>aX!$*RC7#F8b z!UjW1eHz(Jny^U-xS~0P5mKa7-V9D-W)ud^Ygo9Ugj;gnkvD=zTM51|kl7Zb8Y8Te nUx$Wqx^rYP@xO~-9i}c3=b!?Y7>PN|?n+9eYFJo|PsjQL*uIIa4LwoplCwgf*k298 zcA?RzzHA0z*Pd0h?7P^^aCWpan+?LSzVK(3`P-fso>@Qswr7Fo!lEK=3yHMX$2dzL zzsEBw@j_9wUt&dD^Tv}xLs53<`~SJXzV<%H75Pr4|6dtfNtTq@_2j6^*{|KYlN=e# zamL*!#zew}Ig4V-al-X;PAPD4w~~S!m+iC+dO3HkE4D2g`P1xiuESLDX}W8#y3_~C rd}H3ZSX_7u delta 358 zcmXAlJuib%6vuy0+o$(FH*Hd3pwYz8v_Yvs+lU}uTS`&XTfG!D3yIZW5ebRhwXxYO zjR}caEaDsZ3PuZVJ!klz^E)rY`F}UxH=VuxJiP$@94c(Gj**;Vni)Z#U{(=jt|3`L zK@wL;cWGX*An8;DTwW9uC0&Y;%S(b~Nw=cKu>+(yc)0OJEnn3lr$0P7 zZTVCB(*LZ_Mc(r3cagNx`uAUxGGXen4EsZnVN74kn4LDSjq68QAIuPBm@t#XDH&_3 ojB-kW3(BPNGGGkzFk$A6JVngpA`SoY`py{%ZZSlgxiJxve@JjT$N&HU diff --git a/conformance/ConformanceJava.class b/conformance/ConformanceJava.class index 74fc5e84088b2940707612687a0b4a9d294fc234..9c1f08c6eaf13638568c4e65e46895799c010042 100644 GIT binary patch delta 3518 zcmbVPd3;pW75>g-lKbY(3mLMI#0U%|Az@eoBm}~mu*ix&5h()Xx z^&tvHSqdT)DWZZ?qjd~;jh2^a?ic@+_Qc6oO9ni z-goP;$nmcZ90pJzvrJ6E8V^eGkOvRr5fe7n>e-_v*5NUejK}q`-o$ilP}r#Ogq}XB zu*tw?6Y z*n_7%n2No6r`ALr_UYMvZ98gW1?o+B(O}}|IG~4v2ARmzcleY zex-$9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|@>DO7P$*5Wj`*ZZ__j#kca;Lf6v`*00D#5xS3Rbqmj z;ztk5-YY>IAnYUTCp;`R%O7IdHI5O!NqBR=qn)_CGTpZY@o_uSd#svhK`gx!>OmxUkFPY3FX+Pb+Gt@X zW>okieit(<;-iuHeVw?1pc9sV2Q3Xfzl?(lNnvlL!IlWj+D(!SL?jd0l7$?}M!w{r zNXDZ~@-SWUQ6*6?dTyWrD#W-#E}d-w7w3Nizng)ZI?s!CVOAGryQp$8XAg4ukhu>a zDO$H1KL5>o;AD+C`1=AYNzKWP&qm zOT{PDeTaE6ti#oWcXG$Ay^08uEbfwOESzJ0Wo*L@^kd@(_!6h91#e&#;cCJ)gquk@ ze?^49X;yRKBit*t2X|l_`y(hLq+BErnRSW diff --git a/conformance/ConformanceJava.java b/conformance/ConformanceJava.java index 7badf2a5f5..3a944b51c9 100644 --- a/conformance/ConformanceJava.java +++ b/conformance/ConformanceJava.java @@ -3,6 +3,7 @@ import com.google.protobuf.CodedInputStream; import com.google.protobuf.conformance.Conformance; import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf_test_messages.proto3.TestMessagesProto3; +import com.google.protobuf_test_messages.proto2.TestMessagesProto2; import com.google.protobuf.util.JsonFormat; import com.google.protobuf.util.JsonFormat.TypeRegistry; import java.io.IOException; @@ -54,21 +55,31 @@ class ConformanceJava { private enum BinaryDecoder { BYTE_STRING_DECODER() { @Override - public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + public TestMessagesProto3.TestAllTypes parseProto3(ByteString bytes) throws InvalidProtocolBufferException { return TestMessagesProto3.TestAllTypes.parseFrom(bytes); } + @Override + public TestMessagesProto2.TestAllTypesProto2 parseProto2(ByteString bytes) + throws InvalidProtocolBufferException { + return TestMessagesProto2.TestAllTypesProto2.parseFrom(bytes); + } }, BYTE_ARRAY_DECODER() { @Override - public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + public TestMessagesProto3.TestAllTypes parseProto3(ByteString bytes) throws InvalidProtocolBufferException { return TestMessagesProto3.TestAllTypes.parseFrom(bytes.toByteArray()); } + @Override + public TestMessagesProto2.TestAllTypesProto2 parseProto2(ByteString bytes) + throws InvalidProtocolBufferException { + return TestMessagesProto2.TestAllTypesProto2.parseFrom(bytes.toByteArray()); + } }, ARRAY_BYTE_BUFFER_DECODER() { @Override - public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + public TestMessagesProto3.TestAllTypes parseProto3(ByteString bytes) throws InvalidProtocolBufferException { ByteBuffer buffer = ByteBuffer.allocate(bytes.size()); bytes.copyTo(buffer); @@ -82,10 +93,25 @@ class ConformanceJava { "ByteString based ByteBuffer should not throw IOException.", e); } } + @Override + public TestMessagesProto2.TestAllTypesProto2 parseProto2(ByteString bytes) + throws InvalidProtocolBufferException { + ByteBuffer buffer = ByteBuffer.allocate(bytes.size()); + bytes.copyTo(buffer); + buffer.flip(); + try { + return TestMessagesProto2.TestAllTypesProto2.parseFrom(CodedInputStream.newInstance(buffer)); + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException( + "ByteString based ByteBuffer should not throw IOException.", e); + } + } }, READONLY_ARRAY_BYTE_BUFFER_DECODER() { @Override - public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + public TestMessagesProto3.TestAllTypes parseProto3(ByteString bytes) throws InvalidProtocolBufferException { try { return TestMessagesProto3.TestAllTypes.parseFrom( @@ -97,10 +123,23 @@ class ConformanceJava { "ByteString based ByteBuffer should not throw IOException.", e); } } + @Override + public TestMessagesProto2.TestAllTypesProto2 parseProto2(ByteString bytes) + throws InvalidProtocolBufferException { + try { + return TestMessagesProto2.TestAllTypesProto2.parseFrom( + CodedInputStream.newInstance(bytes.asReadOnlyByteBuffer())); + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException( + "ByteString based ByteBuffer should not throw IOException.", e); + } + } }, DIRECT_BYTE_BUFFER_DECODER() { @Override - public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + public TestMessagesProto3.TestAllTypes parseProto3(ByteString bytes) throws InvalidProtocolBufferException { ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size()); bytes.copyTo(buffer); @@ -114,10 +153,26 @@ class ConformanceJava { "ByteString based ByteBuffer should not throw IOException.", e); } } + @Override + public TestMessagesProto2.TestAllTypesProto2 parseProto2(ByteString bytes) + throws InvalidProtocolBufferException { + ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size()); + bytes.copyTo(buffer); + buffer.flip(); + try { + return TestMessagesProto2.TestAllTypesProto2 + .parseFrom(CodedInputStream.newInstance(buffer)); + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException( + "ByteString based ByteBuffer should not throw IOException.", e); + } + } }, READONLY_DIRECT_BYTE_BUFFER_DECODER() { @Override - public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + public TestMessagesProto3.TestAllTypes parseProto3(ByteString bytes) throws InvalidProtocolBufferException { ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size()); bytes.copyTo(buffer); @@ -132,10 +187,26 @@ class ConformanceJava { "ByteString based ByteBuffer should not throw IOException.", e); } } + @Override + public TestMessagesProto2.TestAllTypesProto2 parseProto2(ByteString bytes) + throws InvalidProtocolBufferException { + ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size()); + bytes.copyTo(buffer); + buffer.flip(); + try { + return TestMessagesProto2.TestAllTypesProto2.parseFrom( + CodedInputStream.newInstance(buffer.asReadOnlyBuffer())); + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException( + "ByteString based ByteBuffer should not throw IOException.", e); + } + } }, INPUT_STREAM_DECODER() { @Override - public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + public TestMessagesProto3.TestAllTypes parseProto3(ByteString bytes) throws InvalidProtocolBufferException { try { return TestMessagesProto3.TestAllTypes.parseFrom(bytes.newInput()); @@ -146,13 +217,27 @@ class ConformanceJava { "ByteString based InputStream should not throw IOException.", e); } } + @Override + public TestMessagesProto2.TestAllTypesProto2 parseProto2(ByteString bytes) + throws InvalidProtocolBufferException { + try { + return TestMessagesProto2.TestAllTypesProto2.parseFrom(bytes.newInput()); + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException( + "ByteString based InputStream should not throw IOException.", e); + } + } }; - public abstract TestMessagesProto3.TestAllTypes parse(ByteString bytes) + public abstract TestMessagesProto3.TestAllTypes parseProto3(ByteString bytes) + throws InvalidProtocolBufferException; + public abstract TestMessagesProto2.TestAllTypesProto2 parseProto2(ByteString bytes) throws InvalidProtocolBufferException; } - private TestMessagesProto3.TestAllTypes parseBinary(ByteString bytes) + private TestMessagesProto3.TestAllTypes parseBinaryToProto3(ByteString bytes) throws InvalidProtocolBufferException { TestMessagesProto3.TestAllTypes[] messages = new TestMessagesProto3.TestAllTypes[BinaryDecoder.values().length]; @@ -163,7 +248,7 @@ class ConformanceJava { boolean hasException = false; for (int i = 0; i < BinaryDecoder.values().length; ++i) { try { - messages[i] = BinaryDecoder.values()[i].parse(bytes); + messages[i] = BinaryDecoder.values()[i].parseProto3(bytes); hasMessage = true; } catch (InvalidProtocolBufferException e) { exceptions[i] = e; @@ -219,16 +304,96 @@ class ConformanceJava { return messages[0]; } + + private TestMessagesProto2.TestAllTypesProto2 parseBinaryToProto2(ByteString bytes) + throws InvalidProtocolBufferException { + TestMessagesProto2.TestAllTypesProto2[] messages = + new TestMessagesProto2.TestAllTypesProto2[BinaryDecoder.values().length]; + InvalidProtocolBufferException[] exceptions = + new InvalidProtocolBufferException[BinaryDecoder.values().length]; + + boolean hasMessage = false; + boolean hasException = false; + for (int i = 0; i < BinaryDecoder.values().length; ++i) { + try { + messages[i] = BinaryDecoder.values()[i].parseProto2(bytes); + hasMessage = true; + } catch (InvalidProtocolBufferException e) { + exceptions[i] = e; + hasException = true; + } + } + + if (hasMessage && hasException) { + StringBuilder sb = + new StringBuilder("Binary decoders disagreed on whether the payload was valid.\n"); + for (int i = 0; i < BinaryDecoder.values().length; ++i) { + sb.append(BinaryDecoder.values()[i].name()); + if (messages[i] != null) { + sb.append(" accepted the payload.\n"); + } else { + sb.append(" rejected the payload.\n"); + } + } + throw new RuntimeException(sb.toString()); + } + + if (hasException) { + // We do not check if exceptions are equal. Different implementations may return different + // exception messages. Throw an arbitrary one out instead. + throw exceptions[0]; + } + + // Fast path comparing all the messages with the first message, assuming equality being + // symmetric and transitive. + boolean allEqual = true; + for (int i = 1; i < messages.length; ++i) { + if (!messages[0].equals(messages[i])) { + allEqual = false; + break; + } + } + + // Slow path: compare and find out all unequal pairs. + if (!allEqual) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < messages.length - 1; ++i) { + for (int j = i + 1; j < messages.length; ++j) { + if (!messages[i].equals(messages[j])) { + sb.append(BinaryDecoder.values()[i].name()) + .append(" and ") + .append(BinaryDecoder.values()[j].name()) + .append(" parsed the payload differently.\n"); + } + } + } + throw new RuntimeException(sb.toString()); + } + + return messages[0]; + } + private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) { - TestMessagesProto3.TestAllTypes testMessage; + com.google.protobuf.AbstractMessage testMessage; + boolean isProto3 = request.getMessageType().equals("proto3"); switch (request.getPayloadCase()) { case PROTOBUF_PAYLOAD: { - try { - testMessage = parseBinary(request.getProtobufPayload()); - } catch (InvalidProtocolBufferException e) { - return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build(); + if (isProto3) { + try { + testMessage = parseBinaryToProto3(request.getProtobufPayload()); + } catch (InvalidProtocolBufferException e) { + return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build(); + } + } else if (request.getMessageType().equals("proto2")) { + try { + testMessage = parseBinaryToProto2(request.getProtobufPayload()); + } catch (InvalidProtocolBufferException e) { + return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build(); + } + } else { + throw new RuntimeException("Protobuf request doesn't have specific payload type."); } break; } @@ -256,8 +421,10 @@ class ConformanceJava { case UNSPECIFIED: throw new RuntimeException("Unspecified output format."); - case PROTOBUF: - return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(testMessage.toByteString()).build(); + case PROTOBUF: { + ByteString MessageString = testMessage.toByteString(); + return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(MessageString).build(); + } case JSON: try {