vert-x3 / vertx-virtual-threads-incubator

Vert.x virtual threads incubator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When the form type is multipart/form data, Async.await becomes invalid , If the form submission is not multipart/form, everything is normal

gaoyuanzong opened this issue · comments

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

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 statements = List.of( "CREATE TABLE MOVIE (ID VARCHAR(16) PRIMARY KEY, TITLE VARCHAR(256) NOT NULL)",
"CREATE TABLE RATING (ID INTEGER IDENTITY PRIMARY KEY, value INTEGER, MOVIE_ID VARCHAR(16))",
"INSERT INTO MOVIE (ID, TITLE) VALUES 'starwars', 'Star Wars'",
"INSERT INTO MOVIE (ID, TITLE) VALUES 'indianajones', 'Indiana Jones'",
"INSERT INTO RATING (VALUE, MOVIE_ID) VALUES 1, 'starwars'",
"INSERT INTO RATING (VALUE, MOVIE_ID) VALUES 5, 'starwars'",
"INSERT INTO RATING (VALUE, MOVIE_ID) VALUES 9, 'starwars'",
"INSERT INTO RATING (VALUE, MOVIE_ID) VALUES 10, 'starwars'",
"INSERT INTO RATING (VALUE, MOVIE_ID) VALUES 4, 'indianajones'",
"INSERT INTO RATING (VALUE, MOVIE_ID) VALUES 7, 'indianajones'",
"INSERT INTO RATING (VALUE, MOVIE_ID) VALUES 3, 'indianajones'",
"INSERT INTO RATING (VALUE, MOVIE_ID) VALUES 9, 'indianajones'"
);
statements.forEach(st -> {
await(client.query(st).execute());
});

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