Apply "instanceof pattern matching" in AbstractRoutingDataSource

Closes gh-28011
This commit is contained in:
lijun695 2022-02-05 20:51:18 +08:00 committed by Sam Brannen
parent 9a0f691e86
commit 1e0e477833
1 changed files with 4 additions and 4 deletions

View File

@ -153,11 +153,11 @@ public abstract class AbstractRoutingDataSource extends AbstractDataSource imple
* @throws IllegalArgumentException in case of an unsupported value type
*/
protected DataSource resolveSpecifiedDataSource(Object dataSource) throws IllegalArgumentException {
if (dataSource instanceof DataSource) {
return (DataSource) dataSource;
if (dataSource instanceof DataSource result) {
return result;
}
else if (dataSource instanceof String) {
return this.dataSourceLookup.getDataSource((String) dataSource);
else if (dataSource instanceof String name) {
return this.dataSourceLookup.getDataSource(name);
}
else {
throw new IllegalArgumentException(