{"record":{"id":"534d741711799490","repo":"quarkusio/quarkus","slug":"no-content","errorCode":null,"errorMessage":"No content","messagePattern":"No content","errorType":"http","errorClass":"NoContentException","httpStatus":204,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/providers/serialisers/PrimitiveBodyHandler.java","lineNumber":29,"sourceCode":"public abstract class PrimitiveBodyHandler {\n\n    public String readFrom(InputStream entityStream, boolean allowEmpty) throws IOException {\n        byte[] bytes;\n        if (entityStream instanceof ByteArrayInputStream) {\n            bytes = new byte[entityStream.available()];\n            entityStream.read(bytes);\n        } else {\n            ByteArrayOutputStream out = new ByteArrayOutputStream();\n            byte[] buf = new byte[1024]; //TODO: fix, needs a pure vert.x async read model\n            int r;\n            while ((r = entityStream.read(buf)) > 0) {\n                out.write(buf, 0, r);\n            }\n            bytes = out.toByteArray();\n        }\n        if (!allowEmpty) {\n            if (bytes.length == 0) {\n                throw new NoContentException(\"No content\");\n            }\n        }\n        return new String(bytes, StandardCharsets.UTF_8);\n    }\n\n}\n","sourceCodeStart":11,"sourceCodeEnd":36,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/providers/serialisers/PrimitiveBodyHandler.java#L11-L36","documentation":"PrimitiveBodyHandler throws a jakarta.ws.rs.NoContentException with message \"No content\" when the entity stream is empty (0 bytes) and empty bodies are not allowed. Several primitive/body readers reuse this helper, which refuses to produce a value from an empty entity.","triggerScenarios":"Receiving an HTTP response with an empty body (e.g. 204 No Content, or a 200 with zero-length body) while the client expects a primitive/String entity.","commonSituations":"Server endpoints changed to return 204 or empty bodies; clients calling DELETE-style endpoints expecting a body; misconfigured server returning nothing on error-free paths.","solutions":["Check the response status/Content-Length before reading an entity and handle 204/empty bodies explicitly","Have the server return a body when clients expect one","Read as Response and inspect the entity presence rather than mapping directly to a primitive"],"exampleFix":"// before\nString body = client.target(url).request().get(String.class); // throws on empty body\n// after\nResponse resp = client.target(url).request().get();\nString body = resp.hasEntity() ? resp.readEntity(String.class) : null;","handlingStrategy":"try-catch","validationCode":"Response resp = client.target(url).request().get();\nif (resp.getStatus() == 204 || !resp.hasEntity()) { return null; } // skip entity read","typeGuard":"boolean hasBody(jakarta.ws.rs.core.Response r) { return r != null && r.hasEntity() && r.getLength() != 0; }","tryCatchPattern":"try {\n    String body = response.readEntity(String.class);\n} catch (NoContentException e) {\n    // server returned an empty body; treat as absent\n    String body = null;\n}","preventionTips":["Check status code and hasEntity() before reading entities","Handle 204 No Content explicitly in client code","Ensure server endpoints return bodies when clients require them"],"tags":["resteasy-reactive","no-content","empty-body","message-body-reader"],"backgroundTag":"empty-response-body","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}