use instanceof that new jdk feature

Comment From: wilkinsona

Thanks very much for the pull-request, unfortunately we're not yet ready to accept Java 17 updates. We're tracking this one in https://github.com/spring-projects/spring-boot/issues/28181 which is currently marked as blocked.

Duplicates #29253.