Open gaoyuanzong opened 1 year ago
Sorry, the above issue seems to be a bug at the moment
code is :
package examples.movierating;
import io.vertx.await.Async; import io.vertx.core.AbstractVerticle; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.Router; import io.vertx.ext.web.handler.BodyHandler; import io.vertx.jdbcclient.JDBCPool;
import java.util.List;
import static io.vertx.await.Async.await;
public class MovieVerticleTest extends AbstractVerticle {
private static JDBCPool client;
@Override public void start() throws Exception { Async async = new Async(vertx); client = JDBCPool.pool(vertx, new JsonObject() .put("url", "jdbc:hsqldb:mem:test?shutdown=true") .put("driver_class", "org.hsqldb.jdbcDriver") .put("max_pool_size-loop", 30) ); async.run(v -> s()); }
public void s() {
List
var router = Router.router(vertx);
router.get("/").handler(ctx -> ctx.response().end("Hello World"));
router.route().handler(BodyHandler.create());
router.route("/upload").handler(v->{
v.fileUploads().forEach(f->{
await(client.preparedQuery("SELECT TITLE FROM MOVIE").execute());
});
v.response().end("upload");
});
// Start the server
await(vertx.createHttpServer()
.requestHandler(router)
.listen(8080));
System.out.println("server started");
}
@Override public void stop() throws Exception { super.stop(); } }
POST http://localhost:8080/upload 500 91 ms POST /upload HTTP/1.1 Authorization: 14288617be8a4bfa805e2e24cbff324a User-Agent: PostmanRuntime/7.32.3 Accept: / Postman-Token: 51df5906-7d63-4b72-936d-fb8f1b62716e Host: localhost:8080 Accept-Encoding: gzip, deflate, br Connection: keep-alive Content-Type: multipart/form-data; boundary=--------------------------705948836925060146042283 Cookie: satoken=fd6c1f2f-b47b-4fb4-839e-348707ff9772 Content-Length: 602061
----------------------------705948836925060146042283 Content-Disposition: form-data; name="12323"; filename="238870.jpg" <238870.jpg> ----------------------------705948836925060146042283--
HTTP/1.1 500 Internal Server Error content-length: 21
Internal Server Error
Environment: jdk 19, vert.x 4.4.4
Request Content :
POST /test HTTP/1.1 Authorization: 14288617be8a4bfa805e2e24cbff324a User-Agent: PostmanRuntime/7.32.3 Accept: / Postman-Token: 0838b7ae-5f48-4f7e-adb1-40752b579440 Host: localhost:7001 Accept-Encoding: gzip, deflate, br Connection: keep-alive Content-Type: multipart/form-data; boundary=--------------------------892028311293841493076041 Cookie: satoken=fd6c1f2f-b47b-4fb4-839e-348707ff9772 Content-Length: 602061
----------------------------892028311293841493076041 Content-Disposition: form-data; name="12323"; filename="238870.jpg" <238870.jpg> ----------------------------892028311293841493076041--
exceptional:
java.lang.IllegalStateException at io.vertx.await.impl.DefaultScheduler.unschedule(DefaultScheduler.java:77) at io.vertx.await.impl.VirtualThreadContext.await(VirtualThreadContext.java:163) at io.vertx.await.Async.await(Async.java:70) at io.vertx.await.Async.await(Async.java:60)
Response response = await(VertxHolder.getVertxRedis().get(key)); if(null != response){ return response.toString(); }
Overall, it runs in async. run (v ->{}) If the form submission is not multipart/form, everything is normal