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

Remove constructor with preFill argument from Pool #6117

Merged
merged 2 commits into from Jul 24, 2020

Conversation

obigu
Copy link
Contributor

@obigu obigu commented Jul 23, 2020

Unfortunately I've realised that the constructor based mechanisms that #5773 introduced to prefill a Pool is bad and should be removed (we can keep calling fill() after instantiation).

Calling a protected method (newObject()) on the constructor is an anti pattern and can cause state consistency issues as the object may not have been fully initialized. A simple example can be seen on ParticleEffectPool in which if we use the constructor passing preFill() as true, newObject() will be called before effecthas been set throwing a NullPointerException.

I should have seen this issue before, sorry for that :(

@NathanSweet
Copy link
Member

Can you add a line to CHANGES?

@obigu
Copy link
Contributor Author

obigu commented Jul 24, 2020

@NathanSweet Done, thanks

@NathanSweet NathanSweet merged commit c3f77fd into libgdx:master Jul 24, 2020
@obigu obigu deleted the revertpool branch September 2, 2020 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants