Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal resources for plugins are not isolated #928

Open
2 tasks done
Thorinwasher opened this issue Dec 7, 2023 · 1 comment · May be fixed by #1003
Open
2 tasks done

Internal resources for plugins are not isolated #928

Thorinwasher opened this issue Dec 7, 2023 · 1 comment · May be fixed by #1003

Comments

@Thorinwasher
Copy link
Contributor

Thorinwasher commented Dec 7, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Are you using the latest version of MockBukkit?

  • I am using the latest version of MockBukkit.

Minecraft Version

1.20.2

Describe the bug

One common internal file for plugins is the config.yml. Whenever the default config is saved, this internal file is used. What I understand from class loading, these internal files are linked with a package name and a classloader. The issue that arrives here is that when multiple plugins are loaded which share the same path for an internal file. Then currently for MockBukkit only one of these instances is possible to get whenever that internal file is fetched. So to say, one of the plugins will get the internal file from the other plugin.

Reproducible Test

@Test
void aTest()
{
    JavaPlugin plugin1 = MockBukkit.load(Plugin1);
    JavaPlugin plugin2 = MockBukkit.load(Plugin2);
    assertDoesNotHaveSameContent(plugin1.class.getResourceAsStream("config.yml"),
        plugin2.class.getResourceAsStream("config.yml")))
}

Anything else?

One solution would be to have the plugins load from completely separate class loaders, this should isolate the resource, therefore avoiding the issue

I have no clue how to do this though. As everything is already loaded by the SystemClassLoader (or whatever it's called) to run the test, i.e. before triggering the MockBukkit#load() command.

@Thorinwasher
Copy link
Contributor Author

  • Fixed for MockBukkit#load(...)
  • Fixed for MockBukkit#loadJar(...)

@Thorinwasher Thorinwasher linked a pull request May 1, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant