Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish LambdaHttpHandler instances #21734

Merged
merged 1 commit into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class LambdaHttpHandler implements RequestHandler<APIGatewayV2HTTPEvent,

private static final int BUFFER_SIZE = 8096;

private static Headers errorHeaders = new Headers();
private static final Headers errorHeaders = new Headers();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think code checkers will complain about the case as it's a constant (same for the other file).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it, what would they complain about?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Case for constants should be LIKE_THIS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the case. You mentioned it, but it just didn't register..

static {
errorHeaders.putSingle("Content-Type", "application/json");
}
Expand Down Expand Up @@ -139,7 +139,7 @@ public void handleMessage(Object msg) {
responseBuilder.setIsBase64Encoded(true);
responseBuilder.setBody(Base64.getEncoder().encodeToString(baos.toByteArray()));
} else {
responseBuilder.setBody(new String(baos.toByteArray(), StandardCharsets.UTF_8));
responseBuilder.setBody(baos.toString(StandardCharsets.UTF_8));
}
}
future.complete(responseBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class LambdaHttpHandler implements RequestHandler<AwsProxyRequest, AwsPro

private static final int BUFFER_SIZE = 8096;

private static Headers errorHeaders = new Headers();
private static final Headers errorHeaders = new Headers();
static {
errorHeaders.putSingle("Content-Type", "application/json");
}
Expand Down Expand Up @@ -126,7 +126,7 @@ public void handleMessage(Object msg) {
responseBuilder.setBase64Encoded(true);
responseBuilder.setBody(Base64.getEncoder().encodeToString(baos.toByteArray()));
} else {
responseBuilder.setBody(new String(baos.toByteArray(), StandardCharsets.UTF_8));
responseBuilder.setBody(baos.toString(StandardCharsets.UTF_8));
}
}
future.complete(responseBuilder);
Expand Down