Getting a "BlockingNotAllowedException" exception message in Red Hat Quarkus Application when reading from "InputStream"

Solution Verified - Updated -

Issue

  • Trying to read from the InputStream of the ContainerRequestContext while filtering requests constantly gets:

    BlockingNotAllowedException: Attempting a blocking read on io thread
    
  • Here is a code snippet where this happens:

     @Provider
     @PreMatching
     public class TestFilter implements ContainerRequestFilter {
       @Context
       HttpServerRequest request;
    
       @Override
       public void filter(ContainerRequestContext containerRequestContext) throws IOException {
           containerRequestContext.getEntityStream().readAllBytes();
           //TODO: Edit the request body 
       }
     }
    

Environment

  • Red Hat build of Quarkus
    • 3.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content