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

Only cache Streamers with basic configuration #56

Closed
minborg opened this issue Sep 4, 2020 · 2 comments
Closed

Only cache Streamers with basic configuration #56

minborg opened this issue Sep 4, 2020 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@minborg
Copy link
Contributor

minborg commented Sep 4, 2020

There is an infinite number of potentiall StreamConfiguration so we should limit the cache size.

@minborg minborg added the bug Something isn't working label Sep 4, 2020
@minborg minborg added this to the 0.1.2 milestone Sep 4, 2020
@minborg minborg self-assigned this Sep 4, 2020
@minborg
Copy link
Contributor Author

minborg commented Sep 4, 2020

This is a potential fix:

    @Override
    @SuppressWarnings("unchecked")
    public <T> Stream<T> stream(final StreamConfiguration<T> streamConfiguration) {
        requireNonNull(streamConfiguration);
        if (streamConfiguration.joins().isEmpty()) {
            // Only cache simple configuration to limit the number of objects held
            // See https://github.com/speedment/jpa-streamer/issues/56
            return (Stream<T>) streamerCache
                    .computeIfAbsent(streamConfiguration, ec -> new StandardStreamer<>(streamConfiguration, entityManagerFactory))
                    .stream();
        } else {
            // The StandardStreamer::close method never gets called.
            return new StandardStreamer<>(streamConfiguration, entityManagerFactory).stream();
        }
    }

However, the The StandardStreamer::close method never gets called so the renderer remains open.

@minborg minborg removed their assignment Sep 4, 2020
@minborg minborg removed this from the 0.1.2 milestone Sep 4, 2020
@minborg
Copy link
Contributor Author

minborg commented Sep 4, 2020

We could add a close handler to the stream itself.

@minborg minborg added this to the 0.1.2 milestone Sep 4, 2020
@minborg minborg closed this as completed in a407460 Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant