**Build scan:**
https://gradle-enterprise.elastic.co/s/jfq4w6bzdfc44/tests/:server:test/org.elasticsearch.plugins.PluginsServiceTests/classMethod

**Reproduction line:**
`null`

**Applicable branches:**
master

**Reproduces locally?:**
Didn't try

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.plugins.PluginsServiceTests&tests.test=classMethod

**Failure excerpt:**
```
java.io.IOException: Could not remove the following files (in the order of attempts):
   C:\Users\jenkins\workspace\platform-support\211\server\build\testrun\test\temp\org.elasticsearch.plugins.PluginsServiceTests_D6E9C143DF9FF0A4-001\testLoadServiceProviders-002\custom_plugin_string.jar: java.nio.file.FileSystemException: C:\Users\jenkins\workspace\platform-support\211\server\build\testrun\test\temp\org.elasticsearch.plugins.PluginsServiceTests_D6E9C143DF9FF0A4-001\testLoadServiceProviders-002\custom_plugin_string.jar: The process cannot access the file because it is being used by another process
   C:\Users\jenkins\workspace\platform-support\211\server\build\testrun\test\temp\org.elasticsearch.plugins.PluginsServiceTests_D6E9C143DF9FF0A4-001\testLoadServiceProviders-002: java.nio.file.DirectoryNotEmptyException: C:\Users\jenkins\workspace\platform-support\211\server\build\testrun\test\temp\org.elasticsearch.plugins.PluginsServiceTests_D6E9C143DF9FF0A4-001\testLoadServiceProviders-002
   C:\Users\jenkins\workspace\platform-support\211\server\build\testrun\test\temp\org.elasticsearch.plugins.PluginsServiceTests_D6E9C143DF9FF0A4-001\testLoadServiceProviders-001\custom_plugin_integer.jar: java.nio.file.FileSystemException: C:\Users\jenkins\workspace\platform-support\211\server\build\testrun\test\temp\org.elasticsearch.plugins.PluginsServiceTests_D6E9C143DF9FF0A4-001\testLoadServiceProviders-001\custom_plugin_integer.jar: The process cannot access the file because it is being used by another process
   C:\Users\jenkins\workspace\platform-support\211\server\build\testrun\test\temp\org.elasticsearch.plugins.PluginsServiceTests_D6E9C143DF9FF0A4-001\testLoadServiceProviders-001: java.nio.file.DirectoryNotEmptyException: C:\Users\jenkins\workspace\platform-support\211\server\build\testrun\test\temp\org.elasticsearch.plugins.PluginsServiceTests_D6E9C143DF9FF0A4-001\testLoadServiceProviders-001
   C:\Users\jenkins\workspace\platform-support\211\server\build\testrun\test\temp\org.elasticsearch.plugins.PluginsServiceTests_D6E9C143DF9FF0A4-001: java.nio.file.DirectoryNotEmptyException: C:\Users\jenkins\workspace\platform-support\211\server\build\testrun\test\temp\org.elasticsearch.plugins.PluginsServiceTests_D6E9C143DF9FF0A4-001

  at __randomizedtesting.SeedInfo.seed([D6E9C143DF9FF0A4]:0)
  at org.apache.lucene.util.IOUtils.rm(IOUtils.java:341)
  at org.apache.lucene.tests.util.TestRuleTemporaryFilesCleanup.afterAlways(TestRuleTemporaryFilesCleanup.java:209)
  at com.carrotsearch.randomizedtesting.rules.TestRuleAdapter$1.afterAlways(TestRuleAdapter.java:31)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:43)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:53)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
  at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
  at org.apache.lucene.tests.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:47)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl.lambda$forkTimeoutingTask$0(ThreadLeakControl.java:850)
  at java.lang.Thread.run(Thread.java:833)

```
server/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java
import org.elasticsearch.plugins.ActionPlugin;
            import org.elasticsearch.plugins.Plugin;
            public final class FooPlugin extends Plugin implements ActionPlugin { }
            """, "r.FooTestService", Strings.format("""
            package r;
            import org.elasticsearch.plugins.spi.TestService;
            public final class FooTestService implements TestService {
                @Override
                public String name() {
                    return "%s";
                }
            }
            """, name));
        var classToBytes = InMemoryJavaCompiler.compile(sources);
        Map<String, byte[]> jarEntries = new HashMap<>();
        jarEntries.put("r/FooPlugin.class", classToBytes.get("r.FooPlugin"));
        jarEntries.put("r/FooTestService.class", classToBytes.get("r.FooTestService"));
        jarEntries.put("META-INF/services/org.elasticsearch.plugins.spi.TestService", "r.FooTestService".getBytes(StandardCharsets.UTF_8));
        Path topLevelDir = createTempDir(getTestName());
        Path jar = topLevelDir.resolve(Strings.format("custom_plugin_%s.jar", name));
        JarUtils.createJarWithEntries(jar, jarEntries);
        URL[] urls = new URL[] { jar.toUri().toURL() };
        URLClassLoader loader = URLClassLoader.newInstance(urls, this.getClass().getClassLoader());
        return loader;
    }
    public void testLoadServiceProviders() throws Exception {
        URLClassLoader fakeClassLoader = buildTestProviderPlugin("integer");
        URLClassLoader fakeClassLoader1 = buildTestProviderPlugin("string");
        try {
            @SuppressWarnings("unchecked")