pulsar
pulsar copied to clipboard
[fix][misc] Preserve empty String values in FieldParser
Motivation
FieldParser.setEmptyValue is intended to clear String and boxed numeric fields when a configuration property is present but blank. The String branch currently checks fieldType.getClass().equals(String.class), which compares Class.class to String.class and never matches. As a result, an existing String field value is left unchanged when the property value is empty.
Modifications
- Check field.getType().equals(String.class) when handling empty values.
- Add a regression test that verifies an empty property clears an existing String field.
Verifying this change
This change added tests and can be verified as follows:
- Added FieldParserTest.testEmptyValueClearsStringField.
- Ran git diff --check.
- Not run locally: ./gradlew :pulsar-common:test --tests org.apache.pulsar.common.util.FieldParserTest -PtestRetryCount=0, because this environment has no Java Runtime installed.
Does this pull request potentially affect one of the following parts:
- [ ] Dependencies (add or upgrade a dependency)
- [ ] The public API
- [ ] The schema
- [ ] The default values of configurations
- [ ] The threading model
- [ ] The binary protocol
- [ ] The REST endpoints
- [ ] The admin CLI options
- [ ] The metrics
- [ ] Anything that affects deployment