Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1105,10 +1105,12 @@ private void export(BeanUtilsBean beanUtils, Stack<String> nested, BufferedWrite
stream = stream.filter((Map.Entry<?, ?> entry)-> filterOn.isAssignableFrom(entry.getClass()));
}
stream.forEach(entry -> {
// nested by name
nested.push(entry.getKey().toString());
export(beanUtils, nested, bufferedWriter, entry.getValue());
nested.pop();
if (entry.getValue() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is inconsistent. the check for null to not export a key with for a null value

and the use of String.ValueOf that will write key="null" for a null value.

we should be consistent and write key= for null values and not introduce "null" as we don't understand that as a config value.
This means we need to check for a null value and write an empty string ''

// nested by name
nested.push(entry.getKey().toString());
export(beanUtils, nested, bufferedWriter, entry.getValue());
nested.pop();
}
});
}
} else if (isComplexConfigObject(value)) {
Expand Down Expand Up @@ -1168,7 +1170,7 @@ private void export(BeanUtilsBean beanUtils, Stack<String> nested, BufferedWrite
});
} else {
// string form works ok otherwise
exportKeyValue(nested, bufferedWriter, value.toString());
exportKeyValue(nested, bufferedWriter, String.valueOf(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.activemq.artemis.core.config.impl;

import static org.apache.activemq.artemis.core.config.impl.ConfigurationImpl.REDACTED;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
Expand Down Expand Up @@ -3033,6 +3034,16 @@ public void testSecuritySettingPluginFromBrokerProperties() throws Exception {
assertTrue(configuration.getStatus().contains("initialContextFactory"));
}

@Test
public void testExportInvalidPropertyOnAcceptor() throws Exception {
ConfigurationImpl configuration = new ConfigurationImpl();

// useKQueue here would generate a hashMap Value null, what would break the exportAsProperties.
configuration.addAcceptorConfiguration("test", "tcp://0.0.0.0:61616?useKQueue");
File fileOutput = new File(getTestDirfile(), "broker.properties");
assertDoesNotThrow(() -> configuration.exportAsProperties(fileOutput));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for sure should not throw, but should not loose info... I think it should be:

...params.useKQueue=

}

/**
* To test ARTEMIS-926
*/
Expand Down