{"record":{"id":"9061d3786b1179d9","repo":"apache/beam","slug":"failed-to-read-broker-response-content","errorCode":null,"errorMessage":"Failed to read broker response content","messagePattern":"Failed to read broker response content","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/broker/BrokerResponse.java","lineNumber":45,"sourceCode":"import java.util.stream.Collectors;\nimport org.checkerframework.checker.nullness.qual.Nullable;\n\npublic class BrokerResponse {\n  final int code;\n  final String message;\n  @Nullable String content;\n\n  public BrokerResponse(int responseCode, String message, @Nullable InputStream content) {\n    this.code = responseCode;\n    this.message = message;\n    if (content != null) {\n      // Use try-with-resources so the underlying InputStream is always closed once the\n      // response body has been read; otherwise the HTTP connection stream leaks.\n      try (BufferedReader reader =\n          new BufferedReader(new InputStreamReader(content, StandardCharsets.UTF_8))) {\n        this.content = reader.lines().collect(Collectors.joining(\"\\n\"));\n      } catch (IOException e) {\n        throw new UncheckedIOException(\"Failed to read broker response content\", e);\n      }\n    }\n  }\n\n  public static BrokerResponse fromHttpResponse(HttpResponse response) throws IOException {\n    return new BrokerResponse(\n        response.getStatusCode(), response.getStatusMessage(), response.getContent());\n  }\n\n  @Override\n  public String toString() {\n    return \"BrokerResponse{\"\n        + \"code=\"\n        + code\n        + \", message='\"\n        + message\n        + '\\''\n        + \", content=\"","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/broker/BrokerResponse.java#L27-L63","documentation":"BrokerResponse's constructor reads the Solace management broker's HTTP response body into a string via a BufferedReader; an IOException while reading is rethrown as UncheckedIOException with this message. It indicates the broker replied but its body could not be read (stream broken/closed early).","triggerScenarios":"Solace management REST calls (e.g., queue/vpn lookups in SolaceIO Read/Write administration) where the HTTP connection is dropped mid-body, encoding mismatch, or the underlying InputStream is already consumed/closed when BrokerResponse is constructed.","commonSituations":"Broker/management endpoint timeouts killing the socket; intermediary proxy truncating responses; passing an InputStream previously read elsewhere; TLS or auth issues at the management port.","solutions":["Inspect the wrapped IOException cause for the transport-level failure (connection reset, premature EOF).","Retry the management request; transient connection resets are usually resolved by re-running.","Verify connectivity/TLS to the Solace management endpoint (host, port 8080/443, SEMP access).","Ensure you pass a fresh, unconsumed InputStream/HttpResponse to BrokerResponse.fromHttpResponse."],"exampleFix":"// before\nBrokerResponse resp = new BrokerResponse(streamConsumedEarlier);\n// after\nBrokerResponse resp = BrokerResponse.fromHttpResponse(httpClient.send(request, BodyHandlers.ofInputStream()));","handlingStrategy":"retry","validationCode":"// Pre-flight management endpoint check\n// HttpClient.send(managementRequest, BodyHandlers.discarding()); // expect 200 before pipeline","typeGuard":null,"tryCatchPattern":"try { pipeline.run(); }\ncatch (UncheckedIOException e) {\n  if (\"Failed to read broker response content\".equals(e.getMessage())) retryManagementCall();\n  else throw e;\n}","preventionTips":["Verify management host/port and SEMP permissions before running SolaceIO pipelines.","Pass only fresh HttpResponse/InputStream objects to BrokerResponse.fromHttpResponse.","Add retry with backoff around management REST calls; drop idle/keep-alive connections."],"tags":["solace","http","io","broker"],"backgroundTag":"file-read-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}