-
Notifications
You must be signed in to change notification settings - Fork 81
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
fix: start context in MicronautRequestStreamHandler #1985
Conversation
Close: #1913 This PR changes so the MicronautRequestStreamHandler constructor starts the application context, and it invokes `inject(this)` for the handler to resolve injection points.
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth changing MicronautRequestStreamHandler
so it's exactly the same as MicronautRequestHandler
?
diff --git a/function-aws/src/main/java/io/micronaut/function/aws/MicronautRequestStreamHandler.java b/function-aws/src/main/java/io/micronaut/function/aws/MicronautRequestStreamHandler.java
index 809c7a3f4..d5dc3f6ae 100644
--- a/function-aws/src/main/java/io/micronaut/function/aws/MicronautRequestStreamHandler.java
+++ b/function-aws/src/main/java/io/micronaut/function/aws/MicronautRequestStreamHandler.java
@@ -55,9 +55,13 @@ public class MicronautRequestStreamHandler extends StreamFunctionExecutor<Contex
* Lambda deployment.
*/
public MicronautRequestStreamHandler() {
- buildApplicationContext(null);
- startEnvironment(applicationContext);
- injectIntoApplicationContext();
+ try {
+ buildApplicationContext(null);
+ injectIntoApplicationContext();
+ } catch (Exception e) {
+ LOG.error("Exception initializing handler", e);
+ throw e;
+ }
}
/**
@@ -66,8 +70,14 @@ public class MicronautRequestStreamHandler extends StreamFunctionExecutor<Contex
*/
public MicronautRequestStreamHandler(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
- startEnvironment(applicationContext);
- injectIntoApplicationContext();
+
+ try {
+ startEnvironment(applicationContext);
+ injectIntoApplicationContext();
+ } catch (Exception e) {
+ LOG.error("Exception initializing handler: " + e.getMessage() , e);
+ throw e;
+ }
}
private void injectIntoApplicationContext() {
@@ -91,12 +101,9 @@ public class MicronautRequestStreamHandler extends StreamFunctionExecutor<Contex
@Override
protected ApplicationContext buildApplicationContext(Context context) {
- try {
- return super.buildApplicationContext(context);
- } catch (Exception e) {
- LOG.error("Exception initializing handler: " + e.getMessage(), e);
- throw e;
- }
+ applicationContext = super.buildApplicationContext(context);
+ startEnvironment(applicationContext);
+ return applicationContext;
}
@NonNull
It might make future comparison easier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think the code suggested above is more correct... It sets this.applicationContext
which I cannot see happening in this PR?
Ahhh, I see... that happens in |
Close: #1913
This PR changes so the MicronautRequestStreamHandler constructor starts the application context, and it invokes
inject(this)
for the handler to resolve injection points.