Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Avoid crashing on invalid Plugin annotations #402

Merged

Conversation

ImMorpheus
Copy link
Contributor

@ImMorpheus ImMorpheus commented Jan 20, 2019

An InvalidPluginException is thrown, the plugin is skipped and the exception printed.
I think I've covered every possible case.

Fix #373

@@ -55,12 +56,21 @@ public void visit(String name, Object value) {
checkNotNull(name, "name");
switch (name) {
case "id":
if (!(value instanceof String)) {
throw new InvalidPluginException("Plugin annotation has invalid element 'id'");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plugin annotation -> Dependency annotation for all exceptions in this file.

checkState(State.DEFAULT);
checkNotNull(name, "name");
if (name == null) {
throw new InvalidPluginException("Plugin annotation has null element");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify that name is null, e.g. Plugin annotation attribute name is null

@ImMorpheus ImMorpheus merged commit 070eda1 into SpongePowered:stable-7 Feb 1, 2019
@ImMorpheus ImMorpheus deleted the fix/invalid-annotation branch February 1, 2019 15:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants