-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Different Behavior At Test/Runtime Regarding HTTP Controller #8240
Comments
Indeed it works at test time. It's while running the shadow jar that it
shows the faulty behavior.
…On Thu, Oct 27, 2022 at 3:40 AM Jorge F. Sánchez ***@***.***> wrote:
your example app works for me :)
ServerTest > shouldStoreSingleKey() STANDARD_OUT
10:39:17.143 [Test worker] INFO i.m.context.env.DefaultEnvironment - Established active environments: [test]
Request method: POST
Request URI: http://localhost:35107/bug
Proxy: <none>
Request params: <none>
Query params: <none>
Form params: <none>
Path params: <none>
Headers: Accept=*/*
Content-Type=application/json; charset=UTF-8
Cookies: <none>
Multiparts: <none>
Body:
{
"a": "b"
}
HTTP/1.1 200 OK
date: Thu, 27 Oct 2022 08:39:17 GMT
Content-Type: application/json
content-length: 9
connection: keep-alive
{
"a": "b"
}
Request method: GET
Request URI: http://localhost:35107/bug
Proxy: <none>
Request params: <none>
Query params: <none>
Form params: <none>
Path params: <none>
Headers: Accept=*/*
Content-Type=application/json; charset=UTF-8
Cookies: <none>
Multiparts: <none>
Body: <none>
HTTP/1.1 200 OK
date: Thu, 27 Oct 2022 08:39:18 GMT
Content-Type: application/json
content-length: 9
connection: keep-alive
{
"a": "b"
}
—
Reply to this email directly, view it on GitHub
<#8240 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARQOIPUYIM3LXE43JO6UDLWFI5ZLANCNFSM6AAAAAARPOIPCA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@dstepanov this is another bug caused by #7635 – this time it's @ElderMael The issue appears because you have two concurrent ApplicationContext instances, one from micronaut picocli, one you create yourself. It's a bug on our end that this doesn't work, but you can work around it by using one context like this: Index: src/main/java/io/eldermael/micronaut/bug/demo/client/BugDemoCommand.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/io/eldermael/micronaut/bug/demo/client/BugDemoCommand.java b/src/main/java/io/eldermael/micronaut/bug/demo/client/BugDemoCommand.java
--- a/src/main/java/io/eldermael/micronaut/bug/demo/client/BugDemoCommand.java (revision e301423a50cca8767a68dc69bd806f74e5c60a9e)
+++ b/src/main/java/io/eldermael/micronaut/bug/demo/client/BugDemoCommand.java (date 1667831044023)
@@ -1,8 +1,7 @@
package io.eldermael.micronaut.bug.demo.client;
-import io.eldermael.micronaut.bug.demo.Application;
-import io.eldermael.micronaut.bug.demo.server.Server;
-import io.micronaut.runtime.Micronaut;
+import io.micronaut.runtime.server.EmbeddedServer;
+import jakarta.inject.Inject;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
@@ -17,6 +16,9 @@
@Option(names = {"--server"}, description = "...")
boolean server;
+ @Inject
+ EmbeddedServer embeddedServer;
+
public void run() {
// business logic here
if (verbose) {
@@ -24,7 +26,7 @@
}
if(this.server) {
- Micronaut.run(Server.class, Application.getArgs());
+ embeddedServer.start();
}
}
} You also need some code to keep the application running after this, otherwise it will just shut down immediately. |
Don't think this is a bug on our end or something we can do about. |
Expected Behavior
A response is sent back to the server with the serialized JSON sent.
This application does pass the E2E tests written with RestAssured, at test time, the Controller seems to have the right behavior, but once the server is started without the test environment profile, the Controller stops working.
If one runs
gradle test
, the test environment and HTTP server start and process the requests without issues. But running the server with thejava -jar
command shows a different behavior.Actual Behaviour
The
/bug
endpoint returns a HTTP 400 response. Fails with the following error:Client side:
Server side HTTP exchange:
Steps To Reproduce
Send an HTTP request to the
/bug
endpoint with any JSON payload. In this case the example application can send an http request using the following command:Environment Information
Pop OS/Mac OS
micronaut cli 3.7.2
java oracle-17
Example Application
https://github.com/ElderMael/micronaut-bug-demo
Version
3.6.2
The text was updated successfully, but these errors were encountered: