Copilot commented on code in PR #16305:
URL: https://github.com/apache/iotdb/pull/16305#discussion_r2309424185


##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/ConfigurationFileUtils.java:
##########
@@ -361,4 +335,102 @@ public interface LoadHotModifiedPropsFunc {
     void loadHotModifiedProperties(TrimProperties properties)
         throws IOException, InterruptedException;
   }
+
+  public static Map<String, DefaultConfigurationItem> 
getConfigurationItemsFromTemplate(
+      boolean withDesc) throws IOException {
+    if (configuration2DefaultValue != null && !withDesc) {
+      return configuration2DefaultValue;
+    }
+    Map<String, DefaultConfigurationItem> items = new LinkedHashMap<>();
+    try (InputStream inputStream =
+            ConfigurationFileUtils.class
+                .getClassLoader()
+                .getResourceAsStream(CommonConfig.SYSTEM_CONFIG_TEMPLATE_NAME);
+        InputStreamReader isr = new InputStreamReader(inputStream);
+        BufferedReader reader = new BufferedReader(isr)) {
+      List<String> independentLines = new ArrayList<>();
+      EffectiveModeType effectiveMode = null;
+      StringBuilder description = new StringBuilder();
+      String line;
+      while ((line = reader.readLine()) != null) {
+        line = line.trim();
+        if (line.isEmpty()) {
+          description = new StringBuilder();
+          effectiveMode = null;
+          independentLines.clear();
+          continue;
+        }
+        if (line.startsWith("#")) {
+          String comment = line.substring(1).trim();
+          if (comment.isEmpty()) {
+            continue;
+          }
+          if (comment.startsWith(EFFECTIVE_MODE_PREFIX)) {
+            effectiveMode =
+                EffectiveModeType.getEffectiveMode(
+                    comment.substring(EFFECTIVE_MODE_PREFIX.length()).trim());
+            independentLines.add(comment);
+            continue;
+          } else if (comment.startsWith(DATATYPE_PREFIX)) {
+            independentLines.add(comment);
+            continue;
+          } else {
+            description.append(" ");
+          }
+          if (withDesc) {
+            description.append(comment);
+          }
+        } else {
+          int equalsIndex = line.indexOf('=');

Review Comment:
   Potential StringIndexOutOfBoundsException if a line doesn't contain '=' 
character. The code should check if equalsIndex is -1 before using it for 
substring operations.
   ```suggestion
             int equalsIndex = line.indexOf('=');
             if (equalsIndex == -1) {
               // Skip lines without '=' to avoid 
StringIndexOutOfBoundsException
               continue;
             }
   ```



##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/ConfigurationFileUtils.java:
##########
@@ -36,25 +36,22 @@
 import java.nio.file.Files;
 import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
 import java.util.StringJoiner;
 import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 public class ConfigurationFileUtils {
 
   private static final String lockFileSuffix = ".lock";
   private static final long maxTimeMillsToAcquireLock = 
TimeUnit.SECONDS.toMillis(20);
   private static final long waitTimeMillsPerCheck = 
TimeUnit.MILLISECONDS.toMillis(100);
-  private static Logger logger = 
LoggerFactory.getLogger(ConfigurationFileUtils.class);
+  private static final Logger logger = 
LoggerFactory.getLogger(ConfigurationFileUtils.class);

Review Comment:
   The logger field should not be static final when it was previously 
non-static. This change could affect logging behavior in multi-threaded 
environments or when the class is subclassed.



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java:
##########
@@ -764,7 +765,8 @@ public boolean isSeedConfigNode() {
     }
   }
 
-  public void loadHotModifiedProps(TrimProperties properties) {
+  public void loadHotModifiedProps(TrimProperties properties) throws 
IOException {
+    ConfigurationFileUtils.updateAppliedProperties(properties, true);

Review Comment:
   Adding IOException to the throws clause of an existing public method is a 
breaking change that could affect existing callers who don't handle this 
exception.
   ```suggestion
     public void loadHotModifiedProps(TrimProperties properties) {
       try {
         ConfigurationFileUtils.updateAppliedProperties(properties, true);
       } catch (IOException e) {
         LOGGER.error("Failed to update applied properties", e);
         return;
       }
   ```



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java:
##########
@@ -1960,7 +1961,8 @@ private String[][] parseDataDirs(String dataDirs) {
   }
 
   public synchronized void loadHotModifiedProps(TrimProperties properties)
-      throws QueryProcessException {
+      throws QueryProcessException, IOException {

Review Comment:
   Adding IOException to the throws clause of an existing public method is a 
breaking change that could affect existing callers who don't handle this 
exception.



-- 
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]

Reply via email to