Fix a bug where the warning message is logged in wrong occasion.