Skip to content

Commit

Permalink
feat(transcoding): added better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
zZHorizonZz committed Apr 28, 2024
1 parent b4fe2d6 commit 778e2de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class GrpcTranscodingHttpUtils {
* @param pathTemplate The gRPC path template defining the expected structure.
* @return `true` if the paths match, `false` otherwise.
*/
public static boolean isPathMatch(String requestPath, String pathTemplate) {
public static boolean isPathMatch(String pathTemplate, String requestPath) {
int pathIndex = 0;
int templateIndex = 0;

Expand Down Expand Up @@ -69,7 +69,7 @@ public static Map<String, String> extractPathParams(String pathTemplate, String
String[] pathParts = httpPath.split("/");
String[] templateParts = pathTemplate.split("/");

if(pathParts.length != templateParts.length) {
if (pathParts.length != templateParts.length) {
return extractedParams;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import io.quarkus.grpc.transcoding.GrpcTranscodingMessageWriter;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.DecodeException;

/**
* Tests for {@link GrpcTranscodingMessageWriter}. In this test class, we test the utility methods that are used to merge
Expand Down Expand Up @@ -52,7 +53,7 @@ void testMergeParametersNoPayload() {
@DisplayName("Test mergeParameters with invalid payload")
void testMergeParametersInvalidPayload() {
Buffer invalidPayload = Buffer.buffer("this is not json");
assertThrows(IllegalArgumentException.class, () -> {
assertThrows(DecodeException.class, () -> {
GrpcTranscodingMessageWriter.mergeParameters(new HashMap<>(), new HashMap<>(), invalidPayload);
});
}
Expand Down

0 comments on commit 778e2de

Please sign in to comment.