XD-1439: Prevent module context leak

Please refer to  https://jira.spring.io/browse/XD-1443