Do not directly modify dependency Set provided by the plugin

Modifying the Set directory makes assumptions about the created Set.
About it's type/implementation (maybe it is immutable/read-only?) and about
it's usage/way-of-use that does not break the plugin by adding stuff a Set that might be used differently too etc.
This commit is contained in:
Christian Koop 2024-01-13 17:36:42 +01:00
parent 3f62b36b26
commit 2f1f814d43
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3

View File

@ -23,6 +23,7 @@ import java.io.File;
import java.sql.Connection;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
@ -89,11 +90,10 @@ public abstract class SongodaPlugin extends JavaPlugin {
@Override
public final void onLoad() {
try {
//Load Core dependencies
DependencyLoader.initParentClassLoader(getClass().getClassLoader());
Set<Dependency> dependencies = getDependencies();
Set<Dependency> dependencies = new HashSet<>(getDependencies());
//Use ; instead of . so maven plugin won't relocate it
dependencies.add(new Dependency("https://repo1.maven.org/maven2", "org;apache;commons", "commons-text", "1.9"));
dependencies.add(new Dependency("https://repo1.maven.org/maven2", "org;apache;commons", "commons-lang3", "3.12.0"));