in invoker/core/src/main/java/com/google/cloud/functions/invoker/BackgroundFunctionExecutor.java [325:342]
public void service(HttpServletRequest req, HttpServletResponse res) throws IOException {
String contentType = req.getContentType();
try {
executionIdUtil.storeExecutionId(req);
if ((contentType != null && contentType.startsWith("application/cloudevents+json"))
|| req.getHeader("ce-specversion") != null) {
serviceCloudEvent(req);
} else {
serviceLegacyEvent(req);
}
res.setStatus(HttpServletResponse.SC_OK);
} catch (Throwable t) {
res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
logger.log(Level.SEVERE, "Failed to execute " + functionExecutor.functionName(), t);
} finally {
executionIdUtil.removeExecutionId();
}
}