Annotation Type VirtualThreadStack
Gives every connection's virtual thread at least this much C stack.
A virtual thread's C stack holds native call depth, not Java data, and the default of 64KB is far more than an ordinary handler reaches. A handler that recurses deeply -- a recursive descent parser, a deep template, a regular expression engine -- can still run out, and an overflow there kills the connection's host thread with nothing but an empty reply to show for it. Put this on any class in the backend module to raise the floor:
@VirtualThreadStack("1MB")
@RestController
public class ReportController { ... }
The size is a number of bytes, optionally followed by KB or MB (case
does not matter; 1KB is 1024 bytes). It is read at build time, so a value
that is not a size fails the build and names the class it sits on. When
several classes carry the annotation the largest size wins, the same way
HttpServer.requireVirtualThreadStack only ever raises the size.
The CN1_HTTP_VT_STACK environment variable still applies at start-up, and
the larger of the two is used. The stack is mapped lazily, so a generous
size costs address space rather than memory.
-
Required Element Summary
Required Elements
-
Element Details
-
value
String valueThe minimum C stack per virtual thread: bytes, or a number with aKBorMBsuffix, such as"512KB"or"1MB".
-