Skip to content

Commit 26b5097

Browse files
committed
revert the unsafe function
1 parent a020f50 commit 26b5097

1 file changed

Lines changed: 19 additions & 17 deletions

File tree

rust/operator-binary/src/controller.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -896,17 +896,31 @@ fn build_rolegroup_config_map(
896896

897897
// Add exchange manager properties from resolved fault tolerant execution configuration
898898
if let Some(resolved_fte) = resolved_fte_config {
899-
cm_conf_data.insert(
900-
EXCHANGE_MANAGER_PROPERTIES.to_string(),
901-
unsafe_java_properties_string(&resolved_fte.exchange_manager_properties),
902-
);
899+
if !resolved_fte.exchange_manager_properties.is_empty() {
900+
let exchange_props_with_options: BTreeMap<String, Option<String>> = resolved_fte
901+
.exchange_manager_properties
902+
.iter()
903+
.map(|(k, v)| (k.clone(), Some(v.clone())))
904+
.collect();
905+
cm_conf_data.insert(
906+
EXCHANGE_MANAGER_PROPERTIES.to_string(),
907+
to_java_properties_string(exchange_props_with_options.iter())
908+
.with_context(|_| FailedToWriteJavaPropertiesSnafu)?,
909+
);
910+
}
903911
}
904912

905913
// Add client protocol properties (especially spooling properties)
906914
if let Some(spooling_config) = resolved_spooling_config {
915+
let spooling_props_with_options: BTreeMap<String, Option<String>> = spooling_config
916+
.spooling_manager_properties
917+
.iter()
918+
.map(|(k, v)| (k.clone(), Some(v.clone())))
919+
.collect();
907920
cm_conf_data.insert(
908921
SPOOLING_MANAGER_PROPERTIES.to_string(),
909-
unsafe_java_properties_string(&spooling_config.spooling_manager_properties),
922+
to_java_properties_string(spooling_props_with_options.iter())
923+
.with_context(|_| FailedToWriteJavaPropertiesSnafu)?,
910924
);
911925
}
912926

@@ -950,18 +964,6 @@ fn build_rolegroup_config_map(
950964
})
951965
}
952966

953-
// This is unsafe because it does not do any escaping of keys or values.
954-
// It is needed because the `product_config::writer::to_java_properties_string`
955-
// function escapes `:` characters in values.
956-
// This breaks values like ${file:UTF-8:/path/to/file} which are used
957-
// for S3 credentials.
958-
fn unsafe_java_properties_string(map: &BTreeMap<String, String>) -> String {
959-
map.iter()
960-
.map(|(k, v)| format!("{}={}", k, v))
961-
.collect::<Vec<_>>()
962-
.join("\n")
963-
}
964-
965967
/// The rolegroup catalog [`ConfigMap`] configures the rolegroup catalog based on the configuration
966968
/// given by the administrator
967969
fn build_rolegroup_catalog_config_map(

0 commit comments

Comments
 (0)