You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2026/08/04 06:00:09 UTC
(shardingsphere) branch master updated: Remove isEmpty from YamlConfiguration (#39331)
This is an automated email from the ASF dual-hosted git repository.
terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 959db03e1b2 Remove isEmpty from YamlConfiguration (#39331)
959db03e1b2 is described below
commit 959db03e1b23d36daca2fe4e03a874dee50a45f9
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Aug 4 14:00:02 2026 +0800
Remove isEmpty from YamlConfiguration (#39331)
---
.../shardingsphere/infra/util/yaml/YamlConfiguration.java | 10 ----------
.../apache/shardingsphere/infra/util/yaml/YamlEngineTest.java | 5 +++--
.../fixture/shortcuts/YamlShortcutsConfigurationFixture.java | 6 ------
.../backend/config/yaml/YamlProxyDatabaseConfiguration.java | 6 +++++-
4 files changed, 8 insertions(+), 19 deletions(-)
diff --git a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/YamlConfiguration.java b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/YamlConfiguration.java
index 8b88893eabe..30017c8a634 100644
--- a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/YamlConfiguration.java
+++ b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/YamlConfiguration.java
@@ -21,14 +21,4 @@ package org.apache.shardingsphere.infra.util.yaml;
* YAML configuration.
*/
public interface YamlConfiguration {
-
- /**
- * Check whether the YAML configuration is empty, indicating the absence of any valid configuration items.
- *
- * @return check whether the YAML configuration is empty or not
- */
- default boolean isEmpty() {
- // TODO Only global.yaml and database.yaml handle empty YAML file currently. Other scenarios reading YAML files should also consider overriding this method to check for empty files.
- return false;
- }
}
diff --git a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/YamlEngineTest.java b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/YamlEngineTest.java
index b01f154cd38..a57bd151b34 100644
--- a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/YamlEngineTest.java
+++ b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/YamlEngineTest.java
@@ -36,6 +36,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -57,7 +58,7 @@ class YamlEngineTest {
assertNotNull(url);
YamlShortcutsConfigurationFixture actual = YamlEngine.unmarshal(new File(url.getFile()), YamlShortcutsConfigurationFixture.class);
assertNotNull(actual);
- assertTrue(actual.isEmpty());
+ assertNull(actual.getName());
}
@Test
@@ -72,7 +73,7 @@ class YamlEngineTest {
String yamlContent = SystemResourceFileUtils.readFile("yaml/empty-config.yaml");
YamlShortcutsConfigurationFixture actual = YamlEngine.unmarshal(yamlContent.getBytes(), YamlShortcutsConfigurationFixture.class);
assertNotNull(actual);
- assertTrue(actual.isEmpty());
+ assertNull(actual.getName());
}
@Test
diff --git a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/fixture/shortcuts/YamlShortcutsConfigurationFixture.java b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/fixture/shortcuts/YamlShortcutsConfigurationFixture.java
index 237d7b55fff..282aaf97ec2 100644
--- a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/fixture/shortcuts/YamlShortcutsConfigurationFixture.java
+++ b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/fixture/shortcuts/YamlShortcutsConfigurationFixture.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.infra.util.yaml.fixture.shortcuts;
-import com.google.common.base.Strings;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.infra.util.yaml.YamlConfiguration;
@@ -27,9 +26,4 @@ import org.apache.shardingsphere.infra.util.yaml.YamlConfiguration;
public final class YamlShortcutsConfigurationFixture implements YamlConfiguration {
private String name;
-
- @Override
- public boolean isEmpty() {
- return Strings.isNullOrEmpty(name);
- }
}
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java
index f1bc99c7704..976e06fb183 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/config/yaml/YamlProxyDatabaseConfiguration.java
@@ -41,7 +41,11 @@ public final class YamlProxyDatabaseConfiguration implements YamlConfiguration {
private Collection<YamlRuleConfiguration> rules = new LinkedList<>();
- @Override
+ /**
+ * Check whether the YAML database configuration is empty.
+ *
+ * @return whether the YAML database configuration is empty
+ */
public boolean isEmpty() {
return Strings.isNullOrEmpty(databaseName) && dataSources.isEmpty() && rules.isEmpty();
}