fix for REGISTRY-2248 

[1] https://wso2.org/jira/browse/REGISTRY-2248
[2] https://wso2.org/jira/browse/REGISTRY-2253
[3] https://wso2.org/jira/browse/REGISTRY-2264