Fix for IDENTITY-2053 provided by rajitha@wso2.com