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

Breaking change: stream() semantics when used with stateful generators #869

Merged
merged 1 commit into from Dec 30, 2023

Conversation

armandino
Copy link
Member

With this commit, all root objects created by stream() are independent of each other. This affects the behaviour of stream() when used with stateful generators such as emit(), intSeq(), longSeq().

Example:

List<String> results = Instancio.of(String.class)
    .generate(allStrings(), gen -> gen.emit().items("foo", "bar", "baz").ignoreUnused())
    .stream()
    .limit(3)
    .toList();

// Original behaviour
assertThat(results).containsExactly("foo", "bar", "baz");

// New behaviour
assertThat(results).containsExactly("foo", "foo", "foo");

@armandino armandino added the component: core Issue related to instancio-core label Dec 30, 2023
@armandino armandino self-assigned this Dec 30, 2023
…ors.

With this commit, all root objects created by `stream()` are independent
of each other. This affects the behaviour of `stream()` when used with
stateful generators such as `emit()`, `intSeq()`, `longSeq()`.

Example:

```java
List<String> results = Instancio.of(String.class)
    .generate(allStrings(), gen -> gen.emit().items("foo", "bar", "baz").ignoreUnused())
    .stream()
    .limit(3)
    .toList();

// Original behaviour
assertThat(results).containsExactly("foo", "bar", "baz");

// New behaviour
assertThat(results).containsExactly("foo", "foo", "foo");
```
Copy link

sonarcloud bot commented Dec 30, 2023

@armandino armandino merged commit 4fc4d90 into main Dec 30, 2023
2 checks passed
@armandino armandino deleted the stream-changes branch December 30, 2023 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core Issue related to instancio-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant