0

After upgrading helidon to 2.5.4 and jersey to 2.35, I am getting the following exception in one of the API. With previous version of helidon(2.0.2) and jersey(2.29.1), it used to work fine. Can you please help to resolve this issue.

{"level":"ERROR","logger":"org.glassfish.jersey.server.ServerRuntime$Responder","thread":"jersey-thread-7","ts":1671639547627,"x-request-id":"","msg":"An I/O error has occurred while writing a response message entity to the container output stream.:\norg.glassfish.jersey.server.internal.process.MappableException: java.io.IOException: Bad news: the stream has been closed\n\tat org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:67)\n\tat org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)\n\tat org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1116)\n\tat org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:635)\n\tat org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:373)\n\tat org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:363)\n\tat org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:258)\n\tat org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)\n\tat org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)\n\tat org.glassfish.jersey.internal.Errors.process(Errors.java:292)\n\tat org.glassfish.jersey.internal.Errors.process(Errors.java:274)\n\tat org.glassfish.jersey.internal.Errors.process(Errors.java:244)\n\tat org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)\n\tat org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)\n\tat org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684)\n\tat io.helidon.webserver.jersey.JerseySupport$JerseyHandler.lambda$doAccept$4(JerseySupport.java:335)\n\tat io.helidon.common.context.Contexts.runInContext(Contexts.java:117)\n\tat io.helidon.common.context.ContextAwareExecutorImpl.lambda$wrap$7(ContextAwareExecutorImpl.java:154)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base/java.lang.Thread.run(Thread.java:834)\nCaused by: java.io.IOException: Bad news: the stream has been closed\n\tat io.helidon.webserver.jersey.ResponseWriter$DataChunkOutputStream.awaitRequest(ResponseWriter.java:327)\n\tat io.helidon.webserver.jersey.ResponseWriter$DataChunkOutputStream.write(ResponseWriter.java:186)\n\tat org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:200)\n\tat org.glassfish.jersey.message.internal.WriterInterceptorExecutor$UnCloseableOutputStream.write(WriterInterceptorExecutor.java:276)\n\tat com.fasterxml.jackson.core.json.UTF8JsonGenerator._flushBuffer(UTF8JsonGenerator.java:2171)\n\tat com.fasterxml.jackson.core.json.UTF8JsonGenerator._writeBytes(UTF8JsonGenerator.java:1260)\n\tat com.fasterxml.jackson.core.json.UTF8JsonGenerator.writeFieldName(UTF8JsonGenerator.java:284)\n\tat com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:726)\n\tat com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:774)\n\tat com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)

I also see the below warning whenever the mappableexception is encountered.

{"level":"WARN","logger":"io.helidon.webserver.BareResponseImpl","thread":"jersey-thread-1","ts":1671689369384,"x-request-id":"","msg":"Entity was requested and not fully consumed before a response is sent. This is not supported. Connection will be closed. Please fix your route for POST /demo/api/v2/test/","podname":"deployment-demo-batch-0"}

Below is the signature of the api which errored,

    @post
    @path("test")
    @produces(MediaType.APPLICATION_JSON + "; charset=UTF-8")
    @consumes(MediaType.APPLICATION_JSON + "; charset=UTF-8")
    @timed(name="app_kpi",
    absolute = true,
    reusable = true,
    unit=MetricUnits.NANOSECONDS,displayName="test",
    tags = {"api=test"})
    @tag(name = "Version2")
    @APIResponse(responseCode = "200", description = "Success", content = @content(schema = @Schema(type=SchemaType.ARRAY, implementation = OutputRecord.class)))
    @APIResponse(responseCode = "403", description = "Forbidden")
    @APIResponse(responseCode = "401", description = "Unauthorized")
    @APIResponse(responseCode = "500", description = "An unexpected error occurred during the request.")
    @authenticated
    public Vector<OutputRecords> test(@requestbody(description = "An array of input records to be processed.", required = true,
    content = @content(schema = @Schema(type = SchemaType.ARRAY, implementation = InputRecord.class))) Vector <InputRecords> inputRecords)
Laird Nelson
  • 15,321
  • 19
  • 73
  • 127
Eli Johnes
  • 301
  • 3
  • 13
  • Please share the Jersey API that is mapped to the path along with your exception. SInce the error says "Bad news: the stream has been closed", this is most likely a code bug which is either reading or writing from a stream closed by something else earlier point in time. – Ashwin Prabhu Jan 06 '23 at 12:02
  • Hi Ashwin, i have added the API in the post above now. Please let me know if i am missing something here. – Eli Johnes Jan 06 '23 at 15:27
  • Using Vector in this age is unusual and you must be having some custom converter code to emit Vector. Regardless, have you checked if the vector size matches the size of elements posted to the URI? – Ashwin Prabhu Jan 09 '23 at 12:36
  • @AshwinPrabhu yes, i have checked that. Vector size matches the size of the elements in the URI – Eli Johnes Jan 09 '23 at 15:11
  • Looking at the code it seems to be a unexpected conflict handling: https://github.com/helidon-io/helidon/blob/4ed0d4882bd3beb7a52cdc9fb38169455e854813/webserver/webserver/src/main/java/io/helidon/webserver/BareResponseImpl.java#L215 You would have better luck filing a bug report on Helidon with a simple reproducible or breakdown your API by stripping off all the parameter and requestbody processing layer by layer until you spot the trigger. – Ashwin Prabhu Jan 09 '23 at 17:05

1 Answers1

0

This has been reported as issue 5775 for Helidon.