PDGGK opened a new pull request, #39608:
URL: https://github.com/apache/shardingsphere/pull/39608
Changes proposed in this pull request:
- Fall back to the default execution plan cache when a `SQL_FEDERATION`
rule omits `executionPlanCache`.
`executionPlanCache` is a plain object field on
`YamlSQLFederationRuleConfiguration` with no default, so it is null whenever
the YAML leaves it out:
```yaml
- !SQL_FEDERATION
sqlFederationEnabled: true
```
`swapToObject` then hands that null straight to the cache swapper, which
dereferences it:
```java
SQLFederationCacheOption executionPlanCacheConfig =
executionPlanCacheConfigSwapper.swapToObject(yamlConfig.getExecutionPlanCache());
```
```
java.lang.NullPointerException: Cannot invoke
"...YamlSQLFederationExecutionPlanCacheRuleConfiguration.getInitialCapacity()"
because "yamlConfig" is null
```
Omitting the whole `SQL_FEDERATION` block is fine —
`DefaultSQLFederationRuleConfigurationBuilder` supplies
`DEFAULT_EXECUTION_PLAN_CACHE_OPTION`. It is only writing the rule and leaving
out this one sub-block that fails, which is the more natural thing to do when
all you want is to turn federation on.
The fix uses that same default, so the two ways of not specifying a cache
now agree. Null-guarding a nested YAML config this way is what the encrypt,
sharding and readwrite-splitting swappers already do.
### Tests
`YamlSQLFederationRuleConfigurationSwapperTest#assertSwapToObjectWithoutExecutionPlanCache`
builds the config without the cache block and asserts it comes back as 2000 /
65535. Reverting the change, it errors with the NPE above.
`mvn test -pl kernel/sql-federation/core` — 282 tests, all passing.
---
Before committing this PR, I'm sure that I have checked the following
options:
- [x] My code follows the [code of
conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/)
of this project.
- [x] I have self-reviewed the commit code.
- [ ] I have (or in comment I request) added corresponding labels for the
pull request.
- [x] I have passed maven check locally : `./mvnw clean install -B -T1C
-Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
- [ ] I have made corresponding changes to the documentation.
- [x] I have added corresponding unit tests for my changes.
- [ ] I have updated the Release Notes of the current development version.
For more details, see [Update Release
Note](https://shardingsphere.apache.org/community/en/involved/contribute/contributor/)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]