- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancementA general enhancement
Milestone
Description
Geoffrey De Smet opened SPR-6809 and commented
We got 2 dataSources:
- "productionDB" (also set as defaultTargetDataSource)
- "testDB"
Here is what we expected to return if we ask determineTargetDataSource:
- "productionDB" => the production DB
- "testDB" => the test DB
- null => the production DB
- "testDb" => Exception, but instead we got the production DB
- "nonsence" => Exception, but instead we got the production DB
I think this code:
protected DataSource determineTargetDataSource() {
     Assert.notNull(this.resolvedDataSources, "DataSource router not initialized");
     Object lookupKey = determineCurrentLookupKey();
     DataSource dataSource = (DataSource) this.resolvedDataSources.get(lookupKey);
     if (dataSource == null) {
          dataSource = this.resolvedDefaultDataSource;
     }
     if (dataSource == null) {
          throw new IllegalStateException("Cannot determine target DataSource for lookup key [" + lookupKey + "]");
     }
     return dataSource;
}
should change into this code:
protected DataSource determineTargetDataSource() {
     Assert.notNull(this.resolvedDataSources, "DataSource router not initialized");
     Object lookupKey = determineCurrentLookupKey();
     DataSource dataSource;
     if (lookupKey == null) {
         dataSource = this.resolvedDefaultDataSource;
     } else {
         dataSource = (DataSource) this.resolvedDataSources.get(lookupKey);
         if (dataSource == null) {
             throw new IllegalStateException("Cannot determine target DataSource for lookup key [" + lookupKey + "]");
         }
     }
     return dataSource;
}
Affects: 2.5.5
Referenced from: commits aafe8ef
Metadata
Metadata
Assignees
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancementA general enhancement