Fix for https://issues.jenkins-ci.org/browse/JENKINS-21378

Please review the pull request. Thanks!