Skip to content

Commit 45ea618

Browse files
committed
fixes #91 response headers are not returned if there is an error
1 parent 5ce19a6 commit 45ea618

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

src/main/java/com/networknt/aws/lambda/LightLambdaExchange.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ public APIGatewayProxyResponseEvent getFinalizedResponse(boolean fromListener) {
216216
}
217217
/*
218218
* Check for failures first because a failed request could mean
219-
* that we never set the response in the first place.
219+
* that we never set the response in the first place. If response is not null, don't bother.
220220
*/
221-
if (stateHasAnyFlags(FLAG_REQUEST_HAS_FAILURE | FLAG_RESPONSE_HAS_FAILURE)) {
221+
if (stateHasAnyFlags(FLAG_REQUEST_HAS_FAILURE | FLAG_RESPONSE_HAS_FAILURE) && response == null) {
222222
LOG.error("Exchange has an error, returning middleware status.");
223223
this.state |= FLAG_RESPONSE_DONE;
224224
return ExceptionUtil.convert(this.executor.getChainResults());

src/main/java/com/networknt/aws/lambda/handler/middleware/ExceptionUtil.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
package com.networknt.aws.lambda.handler.middleware;
22
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
3-
import com.fasterxml.jackson.core.JsonProcessingException;
4-
import com.fasterxml.jackson.databind.ObjectMapper;
53
import com.networknt.aws.lambda.utility.HeaderKey;
64
import com.networknt.aws.lambda.utility.HeaderValue;
75
import com.networknt.status.Status;
86

9-
import java.util.ArrayList;
107
import java.util.HashMap;
118
import java.util.List;
129

@@ -16,12 +13,6 @@
1613
*
1714
*/
1815
public class ExceptionUtil {
19-
20-
private static final String DATA_KEY = "data";
21-
private static final String NOTIFICATIONS_KEY = "notifications";
22-
23-
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
24-
2516
/**
2617
* Convert the middleware results to APIGatewayProxyResponseEvent
2718
*

0 commit comments

Comments
 (0)