Skip to content

Conversation

sdelamo
Copy link
Contributor

@sdelamo sdelamo commented Apr 4, 2022

Fixes: #1330

@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 4, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

86.7% 86.7% Coverage
0.0% 0.0% Duplication

@sdelamo sdelamo marked this pull request as ready for review September 6, 2022 11:26
@sdelamo sdelamo marked this pull request as draft September 6, 2022 11:26
@sdelamo sdelamo marked this pull request as ready for review November 17, 2022 05:32
@sdelamo sdelamo requested a review from graemerocher November 17, 2022 05:32
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

86.7% 86.7% Coverage
0.0% 0.0% Duplication


private static Map<String, String> getHeaders(AwsProxyResponse awsProxyResponse) {
Headers multiValueHeaders = awsProxyResponse.getMultiValueHeaders();
Map<String, String> headers = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

use a linked hash map to retain order

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved via 0f624cb

Map<String, String> headers = new HashMap<>();
for (Map.Entry<String, List<String>> entry : multiValueHeaders.entrySet()) {
List<String> headerValues = entry.getValue();
if (headerValues != null && headerValues.size() == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use iterator.hasNext() and iterator.next() instead of calling size() and get(0) which is less efficient

Choose a reason for hiding this comment

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

check: No headers will be added if the size > 1, is this intended?

suggestion: Try this instead headerValues.stream().first().ifPresent(value -> headers.put(entry.getKey(), value));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved via 52b852e

@sdelamo sdelamo changed the base branch from master to 3.16.x April 5, 2023 16:25
@sdelamo sdelamo changed the base branch from 3.16.x to master April 5, 2023 16:25
…/proxy/MicronautResponseWriter.java

Co-authored-by: Thobias Karlsson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Lamba Proxy does not populate response headers correctly

3 participants