Skip to content

Commit a25f883

Browse files
committed
revert the unsafe function
1 parent d464baa commit a25f883

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
@@ -875,17 +875,31 @@ fn build_rolegroup_config_map(
875875

876876
// Add exchange manager properties from resolved fault tolerant execution configuration
877877
if let Some(resolved_fte) = resolved_fte_config {
878-
cm_conf_data.insert(
879-
EXCHANGE_MANAGER_PROPERTIES.to_string(),
880-
unsafe_java_properties_string(&resolved_fte.exchange_manager_properties),
881-
);
878+
if !resolved_fte.exchange_manager_properties.is_empty() {
879+
let exchange_props_with_options: BTreeMap<String, Option<String>> = resolved_fte
880+
.exchange_manager_properties
881+
.iter()
882+
.map(|(k, v)| (k.clone(), Some(v.clone())))
883+
.collect();
884+
cm_conf_data.insert(
885+
EXCHANGE_MANAGER_PROPERTIES.to_string(),
886+
to_java_properties_string(exchange_props_with_options.iter())
887+
.with_context(|_| FailedToWriteJavaPropertiesSnafu)?,
888+
);
889+
}
882890
}
883891

884892
// Add client protocol properties (especially spooling properties)
885893
if let Some(spooling_config) = resolved_spooling_config {
894+
let spooling_props_with_options: BTreeMap<String, Option<String>> = spooling_config
895+
.spooling_manager_properties
896+
.iter()
897+
.map(|(k, v)| (k.clone(), Some(v.clone())))
898+
.collect();
886899
cm_conf_data.insert(
887900
SPOOLING_MANAGER_PROPERTIES.to_string(),
888-
unsafe_java_properties_string(&spooling_config.spooling_manager_properties),
901+
to_java_properties_string(spooling_props_with_options.iter())
902+
.with_context(|_| FailedToWriteJavaPropertiesSnafu)?,
889903
);
890904
}
891905

@@ -929,18 +943,6 @@ fn build_rolegroup_config_map(
929943
})
930944
}
931945

932-
// This is unsafe because it does not do any escaping of keys or values.
933-
// It is needed because the `product_config::writer::to_java_properties_string`
934-
// function escapes `:` characters in values.
935-
// This breaks values like ${file:UTF-8:/path/to/file} which are used
936-
// for S3 credentials.
937-
fn unsafe_java_properties_string(map: &BTreeMap<String, String>) -> String {
938-
map.iter()
939-
.map(|(k, v)| format!("{}={}", k, v))
940-
.collect::<Vec<_>>()
941-
.join("\n")
942-
}
943-
944946
/// The rolegroup catalog [`ConfigMap`] configures the rolegroup catalog based on the configuration
945947
/// given by the administrator
946948
fn build_rolegroup_catalog_config_map(

0 commit comments

Comments
 (0)