-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set a configurable maximum payload size for the message decoder and a…
…dd an invalid message handler to catch invalid messages. Motivation: The gRPC message decoder uses the default limit allowed by the gRPC HTTP/2 transport (2^32 bytes). The default maximum size should be smaller and configurable. Changes: Add options for configuring the maximum message size and use a lower default value (256KB) for both client and server. In addition an invalid message handler can be set on the GrpcReadStream to catch invalid message reports and let the application recover invalid messages. The invalid message handler can be triggered by a capacity overflow or a decoder exception. Results: gRPC server and client now uses a smaller default maximum message size which can be configured according to the application needs. Invalid message handler can also be set to catch invalid messages.
- Loading branch information
Showing
15 changed files
with
476 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
vertx-grpc-common/src/main/java/io/vertx/grpc/common/InvalidMessageException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2011-2024 Contributors to the Eclipse Foundation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
* which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
*/ | ||
package io.vertx.grpc.common; | ||
|
||
import io.vertx.core.VertxException; | ||
|
||
/** | ||
* Signals an invalid message. | ||
* | ||
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a> | ||
*/ | ||
public abstract class InvalidMessageException extends VertxException { | ||
|
||
InvalidMessageException() { | ||
super((String) null, true); | ||
} | ||
|
||
InvalidMessageException(Throwable cause) { | ||
super(cause, true); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
vertx-grpc-common/src/main/java/io/vertx/grpc/common/InvalidMessagePayloadException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2011-2024 Contributors to the Eclipse Foundation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
* which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
*/ | ||
package io.vertx.grpc.common; | ||
|
||
/** | ||
* Signals a message with an invalid payload, i.e. that could not be decoded by the protobuf codec. | ||
* | ||
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a> | ||
*/ | ||
public final class InvalidMessagePayloadException extends InvalidMessageException { | ||
|
||
private GrpcMessage message; | ||
|
||
public InvalidMessagePayloadException(GrpcMessage message, Throwable cause) { | ||
super(cause); | ||
this.message = message; | ||
} | ||
|
||
/** | ||
* @return the invalid message that could not be decoded. | ||
*/ | ||
public GrpcMessage message() { | ||
return message; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
vertx-grpc-common/src/main/java/io/vertx/grpc/common/MessageSizeOverflowException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2011-2024 Contributors to the Eclipse Foundation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
* which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
*/ | ||
package io.vertx.grpc.common; | ||
|
||
/** | ||
* Signals a message that is longer than the maximum configured size. | ||
* | ||
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a> | ||
*/ | ||
public final class MessageSizeOverflowException extends InvalidMessageException { | ||
|
||
private final long messageSize; | ||
|
||
public MessageSizeOverflowException(long messageSize) { | ||
this.messageSize = messageSize; | ||
} | ||
|
||
public long messageSize() { | ||
return messageSize; | ||
} | ||
} |
Oops, something went wrong.