Search in sources :

Example 36 with InvalidProtocolBufferException

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();
            }
        });
    }
}
Also used : WalletException(bisq.core.btc.exceptions.WalletException) Coin(org.bitcoinj.core.Coin) Transaction(org.bitcoinj.core.Transaction) InsufficientBsqException(bisq.core.btc.wallet.InsufficientBsqException) TransactionVerificationException(bisq.core.btc.exceptions.TransactionVerificationException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) InsufficientMoneyException(org.bitcoinj.core.InsufficientMoneyException) CryptoException(bisq.common.crypto.CryptoException) ChangeBelowDustException(bisq.core.btc.wallet.ChangeBelowDustException)

Example 37 with InvalidProtocolBufferException

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());
}
Also used : ResponseEnDeCoderPreV3(org.apache.bookkeeper.proto.BookieProtoEncoding.ResponseEnDeCoderPreV3) ResponseDecoder(org.apache.bookkeeper.proto.BookieProtoEncoding.ResponseDecoder) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ResponseEnDecoderV3(org.apache.bookkeeper.proto.BookieProtoEncoding.ResponseEnDecoderV3) AddResponse(org.apache.bookkeeper.proto.BookieProtocol.AddResponse) Test(org.junit.Test)

Example 38 with InvalidProtocolBufferException

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);
}
Also used : InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) RangeMetadata(org.apache.bookkeeper.stream.proto.RangeMetadata)

Example 39 with InvalidProtocolBufferException

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();
}
Also used : Message(com.google.protobuf.Message) ByteString(com.google.protobuf.ByteString) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ByteString(com.google.protobuf.ByteString)

Example 40 with InvalidProtocolBufferException

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
    }
}
Also used : InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ByteBufCodedInputStream(org.apache.pulsar.common.util.protobuf.ByteBufCodedInputStream) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Aggregations

InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)334 IOException (java.io.IOException)69 ByteString (com.google.protobuf.ByteString)46 ServerRequest (com.pokegoapi.main.ServerRequest)46 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)39 GeneralSecurityException (java.security.GeneralSecurityException)32 CleartextKeysetHandle (com.google.crypto.tink.CleartextKeysetHandle)25 KeysetHandle (com.google.crypto.tink.KeysetHandle)25 HashMap (java.util.HashMap)25 ArrayList (java.util.ArrayList)22 InvalidProtocolBufferException (org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException)22 List (java.util.List)19 Any (com.google.protobuf.Any)18 Map (java.util.Map)18 Key (org.apache.accumulo.core.data.Key)17 Value (org.apache.accumulo.core.data.Value)17 Status (org.apache.accumulo.server.replication.proto.Replication.Status)17 Text (org.apache.hadoop.io.Text)17 HashSet (java.util.HashSet)12 RunnerApi (org.apache.beam.model.pipeline.v1.RunnerApi)11