{"record":{"id":"acdcd6b1e6fcca9b","repo":"flowable/flowable-engine","slug":"io-exception-occurred-acdcd6","errorCode":null,"errorMessage":"IO exception occurred","messagePattern":"IO exception occurred","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-http-common/src/main/java/org/flowable/http/common/impl/apache/ApacheHttpComponentsFlowableHttpClient.java","lineNumber":235,"sourceCode":"                    break;\n                }\n                case \"OPTIONS\":\n                    request = new HttpOptions(uri);\n                    break;\n                default: {\n                    throw new FlowableException(requestInfo.getMethod() + \" HTTP method not supported\");\n                }\n            }\n\n            setHeaders(request, requestInfo.getHttpHeaders());\n            setHeaders(request, requestInfo.getSecureHttpHeaders());\n\n            setConfig(request, requestInfo);\n            return new ApacheHttpComponentsExecutableHttpRequest(request);\n        } catch (URISyntaxException ex) {\n            throw new FlowableException(\"Invalid URL exception occurred\", ex);\n        } catch (IOException ex) {\n            throw new FlowableException(\"IO exception occurred\", ex);\n        }\n    }\n\n    protected URI createUri(String url) throws URISyntaxException {\n        String uri = SPACE_CHARACTER_PATTERN.matcher(url).replaceAll(ENCODED_SPACE_CHARACTER);\n        return new URI(PLUS_CHARACTER_PATTERN.matcher(uri).replaceAll(ENCODED_PLUS_CHARACTER));\n    }\n\n    protected void setRequestEntity(HttpRequest requestInfo, HttpEntityEnclosingRequestBase requestBase) throws UnsupportedEncodingException {\n        if (requestInfo.getBody() != null) {\n            if (StringUtils.isNotEmpty(requestInfo.getBodyEncoding())) {\n                requestBase.setEntity(new StringEntity(requestInfo.getBody(), requestInfo.getBodyEncoding()));\n            } else {\n                requestBase.setEntity(new StringEntity(requestInfo.getBody()));\n            }\n        } else if (requestInfo.getBodyBytes() != null) {\n            // A caller-supplied Content-Type header (added afterwards) takes precedence over this default.\n            requestBase.setEntity(new ByteArrayEntity(requestInfo.getBodyBytes(), ContentType.APPLICATION_OCTET_STREAM));","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-http-common/src/main/java/org/flowable/http/common/impl/apache/ApacheHttpComponentsFlowableHttpClient.java#L217-L253","documentation":"During prepareRequest, any IOException raised while constructing the request (e.g. while building the entity or opening streams) is caught and rethrown as FlowableException('IO exception occurred') with the cause preserved. It signals an I/O-level failure during request preparation, before the request is executed.","triggerScenarios":"An IOException thrown inside prepareRequest — typically while building content/entity parts (e.g. reading a part's content) or other I/O-dependent setup in the Apache client request assembly.","commonSituations":"Multipart parts referencing content that cannot be read; underlying stream closed early; serialization of content failing at the IO layer; occasionally misreported failures when entities are built eagerly.","solutions":["Inspect the wrapped IOException cause in the stack trace to find the true I/O source","Fix the part/content source (ensure files/streams referenced by multipart parts are readable and open)","Retry after checking disk/permission/stream state for content referenced by the request","If caused by eager entity building, restructure the task to pass simple content types"],"exampleFix":"// before\n// part references a stream already consumed by a previous task\nentityBuilder.addBinaryBody(\"file\", alreadyClosedInputStream);\n// after\ntry (InputStream in = new FileInputStream(filePath)) {\n    entityBuilder.addBinaryBody(\"file\", in);\n}","handlingStrategy":"try-catch","validationCode":"// ensure any content/streams referenced by parts are readable before the request\nfor (Part p : parts) {\n    if (p.getSource() instanceof java.io.InputStream in && in.read() == -1 && false) { /* closed check */ }\n}","typeGuard":null,"tryCatchPattern":"try {\n    client.prepareRequest(requestInfo);\n} catch (FlowableException e) {\n    if (\"IO exception occurred\".equals(e.getMessage()) && e.getCause() instanceof java.io.IOException io) {\n        // log io and retry or fail with a descriptive process error\n    } else { throw e; }\n}","preventionTips":["Open streams/files as close as possible to request build time and never reuse consumed streams","Check file permissions and disk state for content referenced by parts","Inspect the wrapped IOException cause rather than the wrapper message"],"tags":["flowable","io","http-client","request-building"],"backgroundTag":"http-request-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}