From 0c75add5e1b087b27ea6af11321b2dad3ba67674 Mon Sep 17 00:00:00 2001 From: Michael Heinrichs Date: Tue, 6 Feb 2024 18:43:18 +0100 Subject: [PATCH] chore: Update PBJ dependency (#11397) Signed-off-by: Michael Heinrichs --- hedera-dependency-versions/build.gradle.kts | 2 +- .../workflows/ParseExceptionWorkaround.java | 47 ------------------- .../app/workflows/TransactionChecker.java | 7 +-- .../workflows/query/QueryWorkflowImpl.java | 8 +--- settings.gradle.kts | 2 +- 5 files changed, 4 insertions(+), 62 deletions(-) delete mode 100644 hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/ParseExceptionWorkaround.java diff --git a/hedera-dependency-versions/build.gradle.kts b/hedera-dependency-versions/build.gradle.kts index 2a7665b8ba36..74a8a2150a4b 100644 --- a/hedera-dependency-versions/build.gradle.kts +++ b/hedera-dependency-versions/build.gradle.kts @@ -55,7 +55,7 @@ moduleInfo { version("com.google.jimfs", "1.2") version("com.google.protobuf", protobufVersion) version("com.google.protobuf.util", protobufVersion) - version("com.hedera.pbj.runtime", "0.7.14") + version("com.hedera.pbj.runtime", "0.7.19") version("com.squareup.javapoet", "1.13.0") version("com.sun.jna", "5.12.1") version("dagger", daggerVersion) diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/ParseExceptionWorkaround.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/ParseExceptionWorkaround.java deleted file mode 100644 index cdd90ed6afd5..000000000000 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/ParseExceptionWorkaround.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hedera.node.app.workflows; - -import com.hedera.pbj.runtime.ParseException; -import edu.umd.cs.findbugs.annotations.NonNull; - -/** - * This is a temporary workaround for an unexpected behavior in PBJ. A {@link ParseException} may be wrapped in - * another {@link ParseException} as its cause. This class provides a method to get the root cause of the - * {@link ParseException}. - * - *

If we agree that {@link ParseException} should not be wrapped in another {@link ParseException}, then this class - * can be removed. - */ -public class ParseExceptionWorkaround { - - private ParseExceptionWorkaround() {} - - /** - * Returns the root cause of the given {@link ParseException}. - * - * @param ex the {@link ParseException} to get the root cause of - * @return the root cause of the given {@link ParseException} - */ - public static Throwable getParseExceptionCause(@NonNull final ParseException ex) { - var cause = ex.getCause(); - while (cause instanceof ParseException) { - cause = cause.getCause(); - } - return cause; - } -} diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/TransactionChecker.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/TransactionChecker.java index 1d262533e8ec..7f4509d0e0a0 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/TransactionChecker.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/TransactionChecker.java @@ -30,7 +30,6 @@ import static com.hedera.hapi.node.base.ResponseCodeEnum.TRANSACTION_HAS_UNKNOWN_FIELDS; import static com.hedera.hapi.node.base.ResponseCodeEnum.TRANSACTION_ID_FIELD_NOT_ALLOWED; import static com.hedera.hapi.node.base.ResponseCodeEnum.TRANSACTION_OVERSIZE; -import static com.hedera.node.app.workflows.ParseExceptionWorkaround.getParseExceptionCause; import static java.util.Collections.emptyList; import static java.util.Objects.requireNonNull; @@ -466,11 +465,7 @@ private T parseStrict( try { return codec.parseStrict(data); } catch (ParseException e) { - - // Temporary workaround for unexpected behavior in PBJ. Can be removed if we agree that - // ParseException should not be wrapped. - final var cause = getParseExceptionCause(e); - if (cause instanceof UnknownFieldException) { + if (e.getCause() instanceof UnknownFieldException) { // We do not allow newer clients to send transactions to older networks. throw new PreCheckException(TRANSACTION_HAS_UNKNOWN_FIELDS); } diff --git a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/query/QueryWorkflowImpl.java b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/query/QueryWorkflowImpl.java index f2f0a58c8801..e67ba1a2e888 100644 --- a/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/query/QueryWorkflowImpl.java +++ b/hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/query/QueryWorkflowImpl.java @@ -24,7 +24,6 @@ import static com.hedera.hapi.node.base.ResponseCodeEnum.PAYER_ACCOUNT_NOT_FOUND; import static com.hedera.hapi.node.base.ResponseType.ANSWER_STATE_PROOF; import static com.hedera.hapi.node.base.ResponseType.COST_ANSWER_STATE_PROOF; -import static com.hedera.node.app.workflows.ParseExceptionWorkaround.getParseExceptionCause; import static java.util.Objects.requireNonNull; import com.hedera.hapi.node.base.AccountID; @@ -302,12 +301,7 @@ private Query parseQuery(Bytes requestBuffer) { try { return queryParser.parseStrict(requestBuffer.toReadableSequentialData()); } catch (ParseException e) { - - // Temporary workaround for unexpected behavior in PBJ. Can be removed if we agree that - // ParseException should not be wrapped. - final var cause = getParseExceptionCause(e); - - switch (cause) { + switch (e.getCause()) { case MalformedProtobufException ex: break; case UnknownFieldException ex: diff --git a/settings.gradle.kts b/settings.gradle.kts index 60b1d6588521..c2d091a2f438 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -143,6 +143,6 @@ dependencyResolutionManagement { version("grpc-proto", "1.45.1") version("hapi-proto", hapiProtoVersion) - plugin("pbj", "com.hedera.pbj.pbj-compiler").version("0.7.14") + plugin("pbj", "com.hedera.pbj.pbj-compiler").version("0.7.19") } }