I'm trying to use response streaming with an AWS Lambda function written in Java and exposed through a Function URL. The handler gives me a Java OutputStream, so I expected to be able to write arbitrary bytes directly. However, writing plain text like `SSSSSSSSSSSSSSSSSSS` results in an Internal Server Error, while writing a JSON-formatted value such as `["SSSSSSSSSSSSSSSSSSS"]` succeeds. Buffered Java responses work for me, and streaming works with Node.js, but I'm trying to determine whether Java supports true response streaming or whether the streaming integration currently requires a specific runtime or response format.
2 Answers
This appears to be a runtime-support limitation rather than a Java version or CPU-architecture problem. AWS documents managed response streaming primarily for Node.js; Java has buffered responses, but it does not expose the same supported streaming handler interface. Unless you implement a supported custom-runtime or lower-level integration, enclosing the text in JSON only makes it acceptable to the buffered response protocol—it does not enable Java response streaming.
The successful JSON result may be misleading—the regular invocation path can interpret that as a valid Lambda response, while plain text does not match the expected response shape. For arbitrary text or binary data, the Function URL must be configured for response streaming and the data must go through the streaming invocation path. Java’s normal buffered handler support does not automatically provide the same streaming behavior as Node.js.
I specifically need to use a Function URL. Buffered Java responses already work, and I was looking for the equivalent of Node.js streaming for larger responses.

That matches what I found: changing Java versions did not help, and the documentation covers streaming for Node.js but not for the Java runtime.