use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project bisq-desktop by bisq-network.
the class ActiveProposalsView method activate.
@Override
protected void activate() {
super.activate();
bsqWalletService.addBsqBalanceListener(this);
onUpdateBalances(bsqWalletService.getAvailableBalance(), bsqWalletService.getPendingBalance(), bsqWalletService.getLockedForVotingBalance(), bsqWalletService.getLockedInBondsBalance());
if (voteButton != null) {
voteButton.setOnAction(e -> {
Coin stake = bsqFormatter.parseToCoin(stakeInputTextField.getText());
// TODO show popup
try {
voteService.publishBlindVote(stake, new FutureCallback<Transaction>() {
@Override
public void onSuccess(@Nullable Transaction result) {
// TODO
}
@Override
public void onFailure(@NotNull Throwable t) {
// TODO
}
});
} catch (CryptoException e1) {
// TODO show error popup
e1.printStackTrace();
} catch (InsufficientBsqException e1) {
e1.printStackTrace();
} catch (WalletException e1) {
e1.printStackTrace();
} catch (TransactionVerificationException e1) {
e1.printStackTrace();
} catch (InsufficientMoneyException e1) {
e1.printStackTrace();
} catch (ChangeBelowDustException e1) {
e1.printStackTrace();
} catch (InvalidProtocolBufferException e1) {
e1.printStackTrace();
}
});
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project bookkeeper by apache.
the class BookieProtoEncodingTest method testV3ResponseDecoderNoFallback.
@Test
public void testV3ResponseDecoderNoFallback() throws Exception {
AddResponse v2Resp = AddResponse.create(BookieProtocol.CURRENT_PROTOCOL_VERSION, BookieProtocol.EOK, 1L, 2L);
BookkeeperProtocol.Response v3Resp = BookkeeperProtocol.Response.newBuilder().setHeader(BKPacketHeader.newBuilder().setVersion(ProtocolVersion.VERSION_THREE).setTxnId(1L).setOperation(OperationType.ADD_ENTRY).build()).setStatus(StatusCode.EOK).setAddResponse(BookkeeperProtocol.AddResponse.newBuilder().setStatus(StatusCode.EOK).setLedgerId(1L).setEntryId(2L).build()).build();
List<Object> outList = Lists.newArrayList();
ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);
when(ctx.fireChannelRead(any())).thenAnswer((iom) -> {
outList.add(iom.getArgument(0));
return null;
});
ResponseEnDeCoderPreV3 v2Encoder = new ResponseEnDeCoderPreV3(null);
ResponseEnDecoderV3 v3Encoder = new ResponseEnDecoderV3(null);
ResponseDecoder v3Decoder = new ResponseDecoder(null, false);
try {
v3Decoder.channelRead(ctx, v2Encoder.encode(v2Resp, UnpooledByteBufAllocator.DEFAULT));
fail("V3 response decoder should fail on decoding v2 response");
} catch (InvalidProtocolBufferException e) {
// expected
}
assertEquals(0, outList.size());
v3Decoder.channelRead(ctx, v3Encoder.encode(v3Resp, UnpooledByteBufAllocator.DEFAULT));
assertEquals(1, outList.size());
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project bookkeeper by apache.
the class MetaRangeImpl method loadRangeMetadata.
private void loadRangeMetadata(long streamId, long rangeId, byte[] rangeMetadataBytes) {
checkArgument(this.streamId == streamId);
checkArgument(rangeId >= 0L);
RangeMetadata metadata;
try {
metadata = RangeMetadata.parseFrom(rangeMetadataBytes);
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException("Invalid range metadata of range (" + streamId + ", " + rangeId + ")", e);
}
this.ranges.put(rangeId, metadata);
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project atlasdb by palantir.
the class ForkedJsonFormat method handleObject.
private static Object handleObject(Tokenizer tokenizer, ExtensionRegistry extensionRegistry, Message.Builder builder, FieldDescriptor field, ExtensionRegistry.ExtensionInfo extension, boolean unknown) throws ParseException {
Message.Builder subBuilder;
if (extension == null) {
subBuilder = builder.newBuilderForField(field);
} else {
subBuilder = extension.defaultInstance.newBuilderForType();
}
if (unknown) {
ByteString data = tokenizer.consumeByteString();
try {
subBuilder.mergeFrom(data);
return subBuilder.build();
} catch (InvalidProtocolBufferException e) {
throw tokenizer.parseException("Failed to build " + field.getFullName() + " from " + data);
}
}
tokenizer.consume("{");
String endToken = "}";
while (!tokenizer.tryConsume(endToken)) {
if (tokenizer.atEnd()) {
throw tokenizer.parseException("Expected \"" + endToken + "\".");
}
mergeField(tokenizer, extensionRegistry, subBuilder);
if (tokenizer.tryConsume(",")) {
// there are more fields in the object, so continue
continue;
}
}
return subBuilder.build();
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project incubator-pulsar by apache.
the class ByteBufCodedInputStreamTest method testByteBufCondedInputStreamTest.
@Test
public void testByteBufCondedInputStreamTest() throws IOException {
ByteBufCodedInputStream inputStream = ByteBufCodedInputStream.get(Unpooled.wrappedBuffer("Test-Message".getBytes()));
assertTrue(inputStream.skipField(WireFormat.WIRETYPE_VARINT));
assertTrue(inputStream.skipField(WireFormat.WIRETYPE_FIXED64));
assertFalse(inputStream.skipField(WireFormat.WIRETYPE_END_GROUP));
inputStream = ByteBufCodedInputStream.get(Unpooled.wrappedBuffer("1000".getBytes()));
assertTrue(inputStream.skipField(WireFormat.WIRETYPE_FIXED32));
try {
inputStream.skipField(WireFormat.WIRETYPE_START_GROUP);
fail("Should not happend");
} catch (Exception e) {
// pass
}
try {
assertTrue(inputStream.skipField(-1));
fail("Should not happend");
} catch (Exception e) {
// pass
}
try {
assertTrue(inputStream.skipField(WireFormat.WIRETYPE_LENGTH_DELIMITED));
fail("Should not happend");
} catch (Exception e) {
// pass
}
try {
inputStream.skipRawBytes(-1);
fail("Should not happend");
} catch (InvalidProtocolBufferException e) {
// pass
}
try {
inputStream.skipRawBytes(10);
fail("Should not happend");
} catch (InvalidProtocolBufferException e) {
// pass
}
}
Aggregations