'new Faker().locality().localeString()' throws java.lang.NullPointerException
gdonoso94 opened this issue · comments
Describe the bug
When using 'new Faker().locality().localeString()' throws java.lang.NullPointerException
To Reproduce
import java.util.UUID;
import lombok.experimental.UtilityClass;
import net.datafaker.Faker;
@UtilityClass
public class MarketMother {
private final Faker FAKER = new Faker();
public Market random() {
return new Market(FAKER.locality().localeString());
}
record Market(String locale) {
}
}
Expected behavior
It should return a fake locale.
Versions:
- OS: macOS Monterrey
- JDK: 17
- Faker Version: 2.1.0
@gdonoso94 could you please clarify how to reproduce the issue?
I don't see any main
or test method in the code snippet you've provided
I added main
public static void main(String[] args) {
System.out.println(MarketMother.random());
}
and it returns
Market[locale=de]
so currently I do not see a problem here
I see, I was using it in a Test.
I've been digging a little bit more and looks like might have something to do with conflicting versions in our pom.
I guess you could close the issue.
@gdonoso94 it seems after some playing I found the issue
it could be reproduced only if datafaker is used as a dep and then there is a resourse file under it
in case of tests inside datafaker we don't need to lookup under the jar so all the tests inside datafaker are passed
please double check whether it fixes your issue
Fixed at #1101
please reopen if it still reproduces