diff --git a/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java b/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java index 8b36da03a60..9fb6fe7ab40 100644 --- a/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java +++ b/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java @@ -172,16 +172,18 @@ public class TestInheritFD { return getProperty("os.name").toLowerCase().contains("win"); } + static Optional lsofCommandCache = stream(new String[][]{ + {"/usr/bin/lsof", "-p"}, + {"/usr/sbin/lsof", "-p"}, + {"/bin/lsof", "-p"}, + {"/sbin/lsof", "-p"}, + {"/usr/local/bin/lsof", "-p"}, + {"/usr/bin/pfiles", "-F"}}) // Solaris + .filter(args -> new File(args[0]).exists()) + .findFirst(); + static Optional lsofCommand() { - return stream(new String[][]{ - {"/usr/bin/lsof", "-p"}, - {"/usr/sbin/lsof", "-p"}, - {"/bin/lsof", "-p"}, - {"/sbin/lsof", "-p"}, - {"/usr/local/bin/lsof", "-p"}, - {"/usr/bin/pfiles", "-F"}}) // Solaris - .filter(args -> new File(args[0]).exists()) - .findFirst(); + return lsofCommandCache; } static Collection outputContainingFilenames() {