This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 9cf25732ed5 (chores) camel-core-catalog: consolidate duplicated code
9cf25732ed5 is described below
commit 9cf25732ed5ae9dd01e87ab0dd4445cb92ba5113
Author: Otavio R. Piske <[email protected]>
AuthorDate: Sun Jul 9 10:01:55 2023 +0200
(chores) camel-core-catalog: consolidate duplicated code
Signed-off-by: Otavio R. Piske <[email protected]>
---
.../camel/catalog/impl/AbstractCamelCatalog.java | 52 ++++++++--------------
1 file changed, 18 insertions(+), 34 deletions(-)
diff --git
a/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java
b/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java
index 9d9b0bd4c55..3f30fca86e6 100644
---
a/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java
+++
b/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/AbstractCamelCatalog.java
@@ -884,21 +884,7 @@ public abstract class AbstractCamelCatalog {
if (!copy.isEmpty()) {
// wrap secret values with RAW to avoid breaking URI encoding
in case of encoded values
- copy.replaceAll((key, val) -> {
- if (val == null) {
- return val;
- }
- BaseOptionModel option = rows.get(key);
- if (option == null) {
- return val;
- }
-
- if (option.isSecret() && !val.startsWith("#") &&
!val.startsWith("RAW(")) {
- return "RAW(" + val + ")";
- }
-
- return val;
- });
+ copy.replaceAll((key, val) -> wrapRAW(key, val, rows));
boolean hasQuestionMark = sb.toString().contains("?");
// the last option may already contain a ? char, if so we
should use & instead of ?
@@ -986,25 +972,7 @@ public abstract class AbstractCamelCatalog {
if (!copy.isEmpty()) {
// wrap secret values with RAW to avoid breaking URI encoding
in case of encoded values
- copy.replaceAll(new BiFunction<String, String, String>() {
- @Override
- public String apply(String key, String val) {
-
- if (val == null) {
- return val;
- }
- BaseOptionModel option = rows.get(key);
- if (option == null) {
- return val;
- }
-
- if (option.isSecret() && !val.startsWith("#") &&
!val.startsWith("RAW(")) {
- return "RAW(" + val + ")";
- }
-
- return val;
- }
- });
+ copy.replaceAll((key, val) -> wrapRAW(key, val, rows));
// the last option may already contain a ? char, if so we
should use & instead of ?
sb.append(hasQuestionmark ? ampersand : '?');
@@ -1027,6 +995,22 @@ public abstract class AbstractCamelCatalog {
}
}
+ private static String wrapRAW(String key, String val, Map<String,
BaseOptionModel> rows) {
+ if (val == null) {
+ return val;
+ }
+ BaseOptionModel option = rows.get(key);
+ if (option == null) {
+ return val;
+ }
+
+ if (option.isSecret() && !val.startsWith("#") &&
!val.startsWith("RAW(")) {
+ return "RAW(" + val + ")";
+ }
+
+ return val;
+ }
+
private static String[] syntaxKeys(String syntax) {
// build tokens between the separators
List<String> tokens = new ArrayList<>();