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

Error when trying to get a list #20

Closed
uiytt opened this issue Feb 9, 2020 · 3 comments
Closed

Error when trying to get a list #20

uiytt opened this issue Feb 9, 2020 · 3 comments
Labels
good first issue Good for newcomers

Comments

@uiytt
Copy link

uiytt commented Feb 9, 2020

Describe the bug
When trying to get a list from a yaml file (or any other file like Json), the first time it returns a string with no error, the second time : an error.

To Reproduce
Use this code :

Yaml YamlConfig = new Yaml("config","storagetest");
String [] defaulteffect = {"test1","test2","test3"};
System.out.println(YamlConfig.getOrSetDefault("test", defaulteffect).getClass());

First time the output is : "class [Ljava.lang.String;"
second time :
"java.lang.ClassCastException: java.util.ArrayList cannot be cast to [Ljava.lang.String;"
Expected behavior
Return a String[] containing "test1","test2" and "test3"

@KotlinFactory KotlinFactory added the bug Something isn't working label Feb 9, 2020
@KotlinFactory
Copy link
Member

Hey uiytt,

Thank you so much for reporting this issue and describing it so highly detailed.
We really appreciate it and it really helps me:)

We've already started figuring it out but it seems very weird.
We will try to fix it soon & push this fix to the next release.

However, until then you could just use a List instead of an array.
We don't know why but we know that this issue doesn't exist with a list instead of an array.
You could use the following code:

Yaml YamlConfig = new Yaml("config","storagetest");
String [] defaulteffect = {"test1","test2","test3"};
System.out.println(YamlConfig.getOrSetDefault("test",  Arrays.asList(defaulteffect)).getClass());

Regards

  • Leonhard

@KotlinFactory KotlinFactory added good first issue Good for newcomers and removed bug Something isn't working labels Feb 14, 2020
@KotlinFactory
Copy link
Member

Hey uiytt,

The issue was resolved in the newest version: 3.0.2

Thanks for reporting it.

Regards,

  • Leonhard

KotlinFactory added a commit that referenced this issue Feb 15, 2020
@KotlinFactory
Copy link
Member

Please try updating to 3.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants