Lock Ruby in CI to v3.1.2 and bump JRuby to v9.4.0.0 (#9196)

Merge pull request 9196