Skip to content
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

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

Open
gaoyuanzong opened this issue Aug 23, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@gaoyuanzong
Copy link

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

@gaoyuanzong gaoyuanzong added the enhancement New feature or request label Aug 23, 2023
@gaoyuanzong
Copy link
Author

Sorry, the above issue seems to be a bug at the moment

@gaoyuanzong
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant