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

Use generics for BasicResourcePool.managed #185

Open
wants to merge 1 commit into
base: 0.11.x
Choose a base branch
from

Conversation

turbanoff
Copy link

I wounder, why can't we add some Generics to avoid ugly casts?

@swaldman
Copy link
Owner

Hi.

Thank you for the pull request!

I feel mean, but I'm unlikely to accept it.

c3p0 is a Java 1.3 library pushed forward in time for more than two decades now. Recent versions don't support Java versions less than 7, so generics are fine in the codebase. But unless there's a strong reason to add later features, I prefer to stick to Java 1.3 style for consistency.

There are tons of places where a newer library would use generics, use the java.util.concurrent libraries etc. But at this point, c3p0's first priority is to remain stable. It lacks the kind of pervasive test suite that would give one confidence that large changes have not broken something.

Where there is a strong reason to do so, c3p0 will adopt newer features. 0.11.x is motivated primarily by developer enthusiasm for loom virtual threads, which has required the use of ReentrantLock/Condition for parts of the library that reky on "pinning" wait()/notify() APIs. Even though the changes are basically mechanical and the user-facing API is unchanged, I've jumped a "major" (for c3p0) version so that I could run a prerelease series. I don't want users to upgrade to a "release" and find a bad surprise

Modifying internal APIs to use newer tools without adding something new that's important to users introduces uncertainty for little payoff. If we're adding a new feature or something, it's fine to implement it with generics or any Java 7+ API (although I still tend to stick to Java 1.3 style if there's no real cost to it). Still, modernizing c3p0 internals just for the sake of modernization would be a big project, potentially destabilizing, with not so much payoff. It's a track I'm hesitant to embark on.

I really do appreciate your time and work. I'm sorry to be discouraging,

@swaldman
Copy link
Owner

swaldman commented Feb 17, 2025

(I can imagine accepting or doing something like this if we were going to make big changes to BasicResourcePool anyway, so that the added typesafety could really help. But I don't see that happening anytime too soon.)

@turbanoff
Copy link
Author

turbanoff commented Feb 17, 2025

There are tons of places where a newer library would use generics, use the java.util.concurrent libraries etc. But at this point, c3p0's first priority is to remain stable.

That's why I don't propose to perform huge refactoring. Just a few small steps, which leads to cleaner and readable code. I don't think it can reduce stableness. Generics actually were introduced to achieve reverse goal - have more type-safety.
But as you wish, of course :)
Thank you for supporting the project.

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