Throw a more detailed error when database connection info is missing

This commit is contained in:
Luck 2018-05-04 21:27:57 +01:00
parent ab8b675bae
commit d8a7d8de4a
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 12 additions and 7 deletions

View File

@ -44,7 +44,7 @@ public class IsolatedClassLoader extends URLClassLoader {
* ClassLoader#getSystemClassLoader returns the AppClassLoader
*
* Calling #getParent on this returns the ExtClassLoader (Java 8) or
* the PlatformClassLoader (Java 8). Since we want this classloader to
* the PlatformClassLoader (Java 9). Since we want this classloader to
* be isolated from the Minecraft server (the app), we set the parent
* to be the platform class loader.
*/

View File

@ -26,6 +26,7 @@
package me.lucko.luckperms.common.storage;
import java.util.Map;
import java.util.Objects;
public class StorageCredentials {
@ -52,19 +53,19 @@ public class StorageCredentials {
}
public String getAddress() {
return this.address;
return Objects.requireNonNull(this.address, "address");
}
public String getDatabase() {
return this.database;
return Objects.requireNonNull(this.database, "database");
}
public String getUsername() {
return this.username;
return Objects.requireNonNull(this.username, "username");
}
public String getPassword() {
return this.password;
return Objects.requireNonNull(this.password, "password");
}
public int getMaxPoolSize() {

View File

@ -111,7 +111,7 @@ public class PermissionRegistry extends RepeatingTask {
// insert the permission into the node structure
TreeNode current = this.rootNode;
for (String part : parts) {
current = current.getChildMap().computeIfAbsent(part, s -> new TreeNode());
current = current.resolve(part);
}
}

View File

@ -38,13 +38,17 @@ public class TreeNode {
private Map<String, TreeNode> children = null;
// lazy init
public synchronized Map<String, TreeNode> getChildMap() {
private synchronized Map<String, TreeNode> getChildMap() {
if (this.children == null) {
this.children = new ConcurrentHashMap<>();
}
return this.children;
}
public TreeNode resolve(String s) {
return getChildMap().computeIfAbsent(s, x -> new TreeNode());
}
public Optional<Map<String, TreeNode>> getChildren() {
return Optional.ofNullable(this.children);
}