fix JENKINS-22009 on 2.2.x branch

cherry-picked the commit from master and applied API changes.
(also had to comment out a test case with compile errors...)