adoroszlai commented on code in PR #10840:
URL: https://github.com/apache/ozone/pull/10840#discussion_r3658435594


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/conf/ConfigurationFieldsTests.java:
##########
@@ -668,6 +677,44 @@ public void testDefaultValueCollision() {
       LOG.info("Checked {} default values for collision.", valuesChecked);
     }
 
+  }
+
+  /**
+   * Verifies no default value in the XML embeds a line break, which would
+   * corrupt the runtime string (see HDDS-8046). Legitimate cases opt out via
+   * {@link #xmlPropsAllowedToContainNewline}. Unlike the comparison tests, 
this
+   * reads the raw XML directly so it is not narrowed by
+   * {@code xmlPropsToSkipCompare}/{@code xmlPrefixToSkipCompare}: every 
property
+   * is checked, and the only exemption is {@link 
#xmlPropsAllowedToContainNewline}.
+   */
+  @Test
+  public void testXmlValuesHaveNoEmbeddedNewlines() {
+    assertNotNull(xmlFilename);
+    Configuration conf = new Configuration(false);
+    conf.setAllowNullValueProperties(true);
+    conf.addResource(xmlFilename);

Review Comment:
   We need to use `OzoneConfiguration` to handle generated configuration files, 
too.  Example violation to reproduce the problem:
   
   ```diff
   --- 
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/OzoneClientConfig.java
   +++ 
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/OzoneClientConfig.java
   @@ -41,7 +41,7 @@ public class OzoneClientConfig {
          defaultValue = "16MB",
          type = ConfigType.SIZE,
          description = "Size which determines at what buffer position a 
partial "
   -          + "flush will be initiated during write. It should be a multiple 
of"
   +          + "flush will be initiated during write.\n\nIt should be a 
multiple of"
              + " ozone.client.stream.buffer.size",
          tags = ConfigTag.CLIENT)
      private long streamBufferFlushSize = 16 * 1024 * 1024;
   ```
   
   Suggestion:
   
   ```java
       Configuration conf = new OzoneConfiguration();
       conf.setAllowNullValueProperties(true);
   ```
   
   - Needs new import as well.
   - Probably worth tweaking the assertion failure message to omit mention of 
`ozone-default.xml`, since that's not the only file where the property may live.
   - I also suggest moving the test case to `TestOzoneConfigurationFields`, 
because `ConfigurationFieldsTests` is mostly supposed to be a copy of Hadoop's 
`TestConfigurationFieldsBase`.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to