ef-labs / vertx-jersey

Run jersey in vert.x
MIT License
150 stars 47 forks source link

swagger example issue #62

Open jenrryyou opened 7 years ago

jenrryyou commented 7 years ago

Hello:

When I run swagger example project(version 4.5.2) in mutiple verticles mode(e.g., (java -jar vertx-jersey-examples-swagger-4.5.2-fat.jar -instances 4 -conf src/test/resources/config.json), something is wrong。Sometimes the response of the url http://localhost:8080/swagger.json is ok, and sometimes returns 404。

If I run jersey server in single verticle mode(e.g., java -jar vertx-jersey-examples-swagger-4.5.2-fat.jar -conf src/test/resources/config.json), everything is ok。

I trace the code and find some code in class org.glassfish.jersey.server.ServerRuntime.java:

public void process(final ContainerRequest request) {
    ...
    requestScope.runInScope(requestScopeInstance, new Runnable() {
    ...
    final RequestProcessingContext data = Stages.process(context, requestProcessingRoot, endpointRef);
    ...
    }
    ...
}

The SwaggerServletContext instance in data.routingContext.matchedResources would miss swagger attribute in some verticles。Is it a bug or I miss something?

adrianluisgonzalez commented 7 years ago

@jenrryyou I have not been able to reproduce with the latest snapshot 4.6.0-SNAPSHOT. This includes a newer version of swagger 1.5.16, perhaps that resolved the issue?

I ran the fat jar with 4 instances as you suggested:

java -jar target/vertx-jersey-examples-swagger-4.6.0-SNAPSHOT-fat.jar  -instances 4 -conf src/test/resources/config.json

Then I cURLed the swagger.json 1000 times:

for ((i=1;i<=1000;i++)); do curl -v "http://localhost:8080/rest/swagger.json"; done

Are you still able to reproduce?