79693950

Date: 2025-07-08 09:03:29
Score: 0.5
Natty:
Report link

Sorry for bringing such old thread, but wouldn't it work with try-finanly ?

Something like:

try { 
    // some actions
    return javax.ws.rs.core.Response.status(200).entity("response").build();
} finally {
   // here I would like to perform an action after the response is sent to the browser
   // for eg. change a state of a file to processed or do a database operation or anything in that manner
}

I would expect that this way - in case the return crashes the service for whatever reason (usually OOM Kill in kubernetes)
the finally part will not be executed, allowing the request to become idempotent

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Ivaylo Ivanov