Thanks Arun Suresh for the fix.
In general, the fix looks correct and I believe it can solve the problem. However I'm a little bit worried about semantics:
Even if in the patch, the event is called "ReleaseTempContainer", since it won't release container immediately, some code path may fail.
For decrease/demote container, RM tells AM container decreased/demoted first, and decrease used resource internally, this is fine.
However, if in the code path, we expect resource released before new resource allocated (like continuous-reservation-looking), otherwise cluster resource will be overflowed temporally.
To avoid misuse this, several naming suggestions:
1) RELEASE_TEMP_CONTAINER (And same for class name)-> RELEASE_CONTAINER (since we don't have special logic to handle "temp" container).
2) "handleTempContainerRelease" -> "asyncReleaseContainer". And add Javadocs to the method to mention, if caller expect containers released before method returns, use completeContainer instead.