An upload endpoint calls `Files.readAllBytes(uploadedFile)` to validate the content before storing it. It works fine in every test, then one production upload of a large file takes down the instance with an `OutOfMemoryError`. What's the actual failure mode, and what should the endpoint do instead?
Files.readAllBytes does exactly what its name says: it reads the entire file into one byte[] in memory before returning anything. A test file of a few kilobytes does this instantly and harmlessly; a real production upload of, say, two gigabytes means allocating a two-gigabyte byte array for a single request, and if that happens for more than one concurrent upload, or the heap simply doesn't have two gigabytes of headroom to spare, the JVM throws OutOfMemoryError — which, unlike a normal exception, can bring down request handling for every other in-flight request on the same instance, not just the upload. The fix is to never load an arbitrary-sized upload fully into memory: stream it directly to storage, and if the content genuinely needs inspecting, read only a bounded prefix rather than the whole thing.