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

Provide a way to unregister a DataSource in SQLErrorCodesFactory [SPR-15006] #19573

Closed
spring-projects-issues opened this issue Dec 12, 2016 · 2 comments
Assignees
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Dec 12, 2016

John Poth opened SPR-15006 and commented

Spring currently caches the datasources and are removed by the Garbage collector once they are no longer used. It would be great to provide a way to allow the user to manually unregister a Datasource and not have to wait until a GC kicks in. This is a problem in OSGI and the current workaround is to get the error codes by Datasource name so the cache isn't used.

So something like:

public DataSource unregisterDatabase(DataSource dataSource) {
		synchronized (this.dataSourceCache) {
			return this.dataSourceCache.put(dataSource);
		}
	}

Would be great!


Affects: 4.3.4

Referenced from: commits 8190e78, b825528

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 12, 2016

Juergen Hoeller commented

I've added an unregisterDatabase(DataSource) method, also changing SQLErrorCodesFactory's internal cache from a WeakHashMap to a our own ConcurrentReferenceHashMap which we're using in all other places these days (for better concurrency and for memory-friendly soft references by default).

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 12, 2016

John Poth commented

That was quick :) Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.