**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
assertThat(PluginsService.toModuleName("module-name!"), equalTo("module.name"));
        assertThat(PluginsService.toModuleName("module!@#name!"), equalTo("module.name"));
        assertThat(PluginsService.toModuleName("!module-name!"), equalTo("module.name"));
        assertThat(PluginsService.toModuleName("module_name"), equalTo("module_name"));
        assertThat(PluginsService.toModuleName("-module-name-"), equalTo("module.name"));
        assertThat(PluginsService.toModuleName("_module_name"), equalTo("_module_name"));
        assertThat(PluginsService.toModuleName("_"), equalTo("_"));
    }
    static final class Loader extends ClassLoader {
        Loader(ClassLoader parent) {
            super(parent);
        }
    }
    
    static void closePluginLoaders(PluginsService pluginService) {
        for (var lp : pluginService.plugins()) {
            if (lp.loader()instanceof URLClassLoader urlClassLoader) {
                try {
                    PrivilegedOperations.closeURLClassLoader(urlClassLoader);
                } catch (IOException unexpected) {
                    throw new UncheckedIOException(unexpected);
                }
            }
        }
    }
    private static class TestExtensiblePlugin extends Plugin implements ExtensiblePlugin {
        private List<TestExtensionPoint> extensions;
        @Override
        public void loadExtensions(ExtensionLoader loader) {
            assert extensions == null;