r/java • • 3d ago

Datafaker 3.0 Released

https://www.datafaker.net/releases/3.0.0/

Hi all,

Thanks to the combined effort of 29 contributors, we've managed to create a new version of Datafaker, version 3.0. It's mostly compatible with Datafaker 2.x, but due to enabling JSpecify in this release, we've decided to call this a (potentially) breaking release. Java 17 is still the baseline, so no changes there, but we've managed to add some features, make it even faster, improved GraalVM support, and a whole lot of other improvements, plus we changed our website, https://www.datafaker.net/, to look slightly more modern.

Big shoutout to everyone who contributed on this! Cheers!

63 Upvotes

11 comments sorted by

View all comments

7

u/pigbearpig 2d ago

why are the email addresses potentially real addresses? they're like first.last@hotmail or yahoo.

10

u/bodiam 2d ago

Because that's the whole point of the library: to make real looking but fake data. It's statistically inevitable that some of the email addresses, names, or geographic addresses match real data.

13

u/elmuerte 2d ago

RFC 2606 defines the .test and .example TLD which are usable for testing. You want your application to accept those (in non-production mode).

3

u/bodiam 2d ago

If you want more control over the generation, you could do something like, which would be more safer in some situations:

String email = faker.credentials().username() + "@something.example";

It really depends on how you want to use the library.

0

u/pigbearpig 2d ago

It doesn't have to be statistically inevitable if you use conventions to avoid that. Somehow the TV and movie industry can figure it out, I think you can too.

1

u/DevWithImagination 10h ago

(In the 2.x stream at least) there is an “internet().safeEmailAddress()” option that returns example.com addresses