fixes https://issues.jenkins-ci.org/browse/JENKINS-23483 and https://issues.jenkins-ci.org/browse/JENKINS-18110