Skip to content

Commit 3a96f35

Browse files
committed
Substitute tabs for spaces
1 parent 224e5fb commit 3a96f35

File tree

5 files changed

+347
-349
lines changed

5 files changed

+347
-349
lines changed

aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/model/AwsProxyRequest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class AwsProxyRequest {
3030

3131
private String body;
3232
private String version;
33-
private String resource;
33+
private String resource;
3434
private AwsProxyRequestContext requestContext;
3535
private MultiValuedTreeMap<String, String> multiValueQueryStringParameters;
3636
private Map<String, String> queryStringParameters;
@@ -97,12 +97,12 @@ public String getResource() {
9797
}
9898

9999
public String getVersion() {
100-
return version;
101-
}
100+
return version;
101+
}
102102

103-
public void setVersion(String version) {
104-
this.version = version;
105-
}
103+
public void setVersion(String version) {
104+
this.version = version;
105+
}
106106

107107
public void setResource(String resource) {
108108
this.resource = resource;

aws-serverless-java-container-springboot3/pom.xml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -287,21 +287,21 @@
287287
</plugins>
288288
</build>
289289
<repositories>
290-
<repository>
291-
<id>spring-snapshots</id>
292-
<name>Spring Snapshots</name>
293-
<url>https://repo.spring.io/snapshot</url>
294-
<snapshots>
295-
<enabled>true</enabled>
296-
</snapshots>
297-
</repository>
298-
<repository>
299-
<id>spring-milestones</id>
300-
<name>Spring Milestones</name>
301-
<url>https://repo.spring.io/milestone</url>
302-
<snapshots>
303-
<enabled>false</enabled>
304-
</snapshots>
305-
</repository>
306-
</repositories>
290+
<repository>
291+
<id>spring-snapshots</id>
292+
<name>Spring Snapshots</name>
293+
<url>https://repo.spring.io/snapshot</url>
294+
<snapshots>
295+
<enabled>true</enabled>
296+
</snapshots>
297+
</repository>
298+
<repository>
299+
<id>spring-milestones</id>
300+
<name>Spring Milestones</name>
301+
<url>https://repo.spring.io/milestone</url>
302+
<snapshots>
303+
<enabled>false</enabled>
304+
</snapshots>
305+
</repository>
306+
</repositories>
307307
</project>

aws-serverless-java-container-springboot3/src/main/java/com/amazonaws/serverless/proxy/spring/SpringDelegatingLambdaContainerHandler.java

Lines changed: 66 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import java.util.concurrent.CountDownLatch;
99
import java.util.concurrent.TimeUnit;
1010

11-
import org.apache.commons.logging.Log;
12-
import org.apache.commons.logging.LogFactory;
1311
import org.springframework.cloud.function.serverless.web.FunctionClassUtils;
1412
import org.springframework.cloud.function.serverless.web.ProxyHttpServletRequest;
1513
import org.springframework.cloud.function.serverless.web.ProxyMvc;
@@ -52,75 +50,75 @@
5250
*/
5351
public class SpringDelegatingLambdaContainerHandler implements RequestStreamHandler {
5452

55-
private final Class<?>[] startupClasses;
56-
57-
private final ProxyMvc mvc;
58-
59-
private final ObjectMapper mapper;
60-
61-
private final AwsProxyHttpServletResponseWriter responseWriter;
62-
63-
public SpringDelegatingLambdaContainerHandler() {
64-
this(new Class[] {FunctionClassUtils.getStartClass()});
65-
}
66-
67-
public SpringDelegatingLambdaContainerHandler(Class<?>... startupClasses) {
68-
this.startupClasses = startupClasses;
69-
this.mvc = ProxyMvc.INSTANCE(this.startupClasses);
70-
this.mapper = new ObjectMapper();
71-
this.responseWriter = new AwsProxyHttpServletResponseWriter();
72-
}
73-
74-
@SuppressWarnings({"rawtypes" })
75-
@Override
76-
public void handleRequest(InputStream input, OutputStream output, Context lambdaContext) throws IOException {
77-
Map request = mapper.readValue(input, Map.class);
78-
SecurityContextWriter securityWriter = "2.0".equals(request.get("version"))
79-
? new AwsHttpApiV2SecurityContextWriter() : new AwsProxySecurityContextWriter();
80-
HttpServletRequest httpServletRequest = "2.0".equals(request.get("version"))
81-
? this.generateRequest2(request, lambdaContext, securityWriter) : this.generateRequest(request, lambdaContext, securityWriter);
82-
83-
CountDownLatch latch = new CountDownLatch(1);
84-
AwsHttpServletResponse httpServletResponse = new AwsHttpServletResponse(httpServletRequest, latch);
85-
try {
86-
mvc.service(httpServletRequest, httpServletResponse);
87-
latch.await(10, TimeUnit.SECONDS);
88-
mapper.writeValue(output, responseWriter.writeResponse(httpServletResponse, lambdaContext));
89-
}
90-
catch (Exception e) {
91-
throw new IllegalStateException(e);
92-
}
93-
}
94-
95-
@SuppressWarnings({ "unchecked", "rawtypes" })
96-
private HttpServletRequest generateRequest(Map request, Context lambdaContext, SecurityContextWriter securityWriter) {
97-
AwsProxyRequest v1Request = this.mapper.convertValue(request, AwsProxyRequest.class);
98-
99-
ProxyHttpServletRequest httpRequest = new ProxyHttpServletRequest(this.mvc.getApplicationContext().getServletContext(),
100-
v1Request.getHttpMethod(), v1Request.getPath());
101-
102-
if (StringUtils.hasText(v1Request.getBody())) {
103-
httpRequest.setContentType("application/json");
104-
httpRequest.setContent(v1Request.getBody().getBytes(StandardCharsets.UTF_8));
105-
}
106-
httpRequest.setAttribute(RequestReader.API_GATEWAY_CONTEXT_PROPERTY, v1Request.getRequestContext());
107-
httpRequest.setAttribute(RequestReader.API_GATEWAY_STAGE_VARS_PROPERTY, v1Request.getStageVariables());
108-
httpRequest.setAttribute(RequestReader.API_GATEWAY_EVENT_PROPERTY, v1Request);
109-
httpRequest.setAttribute(RequestReader.ALB_CONTEXT_PROPERTY, v1Request.getRequestContext().getElb());
110-
httpRequest.setAttribute(RequestReader.LAMBDA_CONTEXT_PROPERTY, lambdaContext);
111-
httpRequest.setAttribute(RequestReader.JAX_SECURITY_CONTEXT_PROPERTY, securityWriter.writeSecurityContext(v1Request, lambdaContext));
112-
return httpRequest;
113-
}
114-
115-
@SuppressWarnings({ "rawtypes", "unchecked" })
116-
public HttpServletRequest generateRequest2(Map request, Context lambdaContext, SecurityContextWriter securityWriter) {
117-
HttpApiV2ProxyRequest v2Request = this.mapper.convertValue(request, HttpApiV2ProxyRequest.class);
53+
private final Class<?>[] startupClasses;
54+
55+
private final ProxyMvc mvc;
56+
57+
private final ObjectMapper mapper;
58+
59+
private final AwsProxyHttpServletResponseWriter responseWriter;
60+
61+
public SpringDelegatingLambdaContainerHandler() {
62+
this(new Class[] {FunctionClassUtils.getStartClass()});
63+
}
64+
65+
public SpringDelegatingLambdaContainerHandler(Class<?>... startupClasses) {
66+
this.startupClasses = startupClasses;
67+
this.mvc = ProxyMvc.INSTANCE(this.startupClasses);
68+
this.mapper = new ObjectMapper();
69+
this.responseWriter = new AwsProxyHttpServletResponseWriter();
70+
}
71+
72+
@SuppressWarnings({"rawtypes" })
73+
@Override
74+
public void handleRequest(InputStream input, OutputStream output, Context lambdaContext) throws IOException {
75+
Map request = mapper.readValue(input, Map.class);
76+
SecurityContextWriter securityWriter = "2.0".equals(request.get("version"))
77+
? new AwsHttpApiV2SecurityContextWriter() : new AwsProxySecurityContextWriter();
78+
HttpServletRequest httpServletRequest = "2.0".equals(request.get("version"))
79+
? this.generateRequest2(request, lambdaContext, securityWriter) : this.generateRequest(request, lambdaContext, securityWriter);
80+
81+
CountDownLatch latch = new CountDownLatch(1);
82+
AwsHttpServletResponse httpServletResponse = new AwsHttpServletResponse(httpServletRequest, latch);
83+
try {
84+
mvc.service(httpServletRequest, httpServletResponse);
85+
latch.await(10, TimeUnit.SECONDS);
86+
mapper.writeValue(output, responseWriter.writeResponse(httpServletResponse, lambdaContext));
87+
}
88+
catch (Exception e) {
89+
throw new IllegalStateException(e);
90+
}
91+
}
92+
93+
@SuppressWarnings({ "unchecked", "rawtypes" })
94+
private HttpServletRequest generateRequest(Map request, Context lambdaContext, SecurityContextWriter securityWriter) {
95+
AwsProxyRequest v1Request = this.mapper.convertValue(request, AwsProxyRequest.class);
96+
97+
ProxyHttpServletRequest httpRequest = new ProxyHttpServletRequest(this.mvc.getApplicationContext().getServletContext(),
98+
v1Request.getHttpMethod(), v1Request.getPath());
99+
100+
if (StringUtils.hasText(v1Request.getBody())) {
101+
httpRequest.setContentType("application/json");
102+
httpRequest.setContent(v1Request.getBody().getBytes(StandardCharsets.UTF_8));
103+
}
104+
httpRequest.setAttribute(RequestReader.API_GATEWAY_CONTEXT_PROPERTY, v1Request.getRequestContext());
105+
httpRequest.setAttribute(RequestReader.API_GATEWAY_STAGE_VARS_PROPERTY, v1Request.getStageVariables());
106+
httpRequest.setAttribute(RequestReader.API_GATEWAY_EVENT_PROPERTY, v1Request);
107+
httpRequest.setAttribute(RequestReader.ALB_CONTEXT_PROPERTY, v1Request.getRequestContext().getElb());
108+
httpRequest.setAttribute(RequestReader.LAMBDA_CONTEXT_PROPERTY, lambdaContext);
109+
httpRequest.setAttribute(RequestReader.JAX_SECURITY_CONTEXT_PROPERTY, securityWriter.writeSecurityContext(v1Request, lambdaContext));
110+
return httpRequest;
111+
}
112+
113+
@SuppressWarnings({ "rawtypes", "unchecked" })
114+
public HttpServletRequest generateRequest2(Map request, Context lambdaContext, SecurityContextWriter securityWriter) {
115+
HttpApiV2ProxyRequest v2Request = this.mapper.convertValue(request, HttpApiV2ProxyRequest.class);
118116
ProxyHttpServletRequest httpRequest = new ProxyHttpServletRequest(this.mvc.getApplicationContext().getServletContext(),
119-
v2Request.getRequestContext().getHttp().getMethod(), v2Request.getRequestContext().getHttp().getPath());
117+
v2Request.getRequestContext().getHttp().getMethod(), v2Request.getRequestContext().getHttp().getPath());
120118

121119
if (StringUtils.hasText(v2Request.getBody())) {
122-
httpRequest.setContentType("application/json");
123-
httpRequest.setContent(v2Request.getBody().getBytes(StandardCharsets.UTF_8));
120+
httpRequest.setContentType("application/json");
121+
httpRequest.setContent(v2Request.getBody().getBytes(StandardCharsets.UTF_8));
124122
}
125123
httpRequest.setAttribute(RequestReader.HTTP_API_CONTEXT_PROPERTY, v2Request.getRequestContext());
126124
httpRequest.setAttribute(RequestReader.HTTP_API_STAGE_VARS_PROPERTY, v2Request.getStageVariables());

0 commit comments

Comments
 (0)