This is an automated email from the ASF dual-hosted git repository.
fjtiradosarti pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-runtimes.git
The following commit(s) were added to refs/heads/main by this push:
new c1e86c1d51 [Fix #3959] Case sensitive check for excluded headers
(#3960)
c1e86c1d51 is described below
commit c1e86c1d51e701df6434963a32b1127712a86f49
Author: Francisco Javier Tirado Sarti
<[email protected]>
AuthorDate: Fri Jun 20 12:21:05 2025 +0200
[Fix #3959] Case sensitive check for excluded headers (#3960)
* [Fix #3959] Case sensitive check for excluded headers
* [Fix #3959] Gabriels comments
---
.../kogito/internal/utils/CaseInsensitiveSet.java | 46 ++++++++++++++++++++++
.../internal/utils/CaseInsensitiveSetTest.java | 46 ++++++++++++++++++++++
.../workflow/openapi/OpenApiWorkItemHandler.java | 4 +-
3 files changed, 94 insertions(+), 2 deletions(-)
diff --git
a/api/kogito-api/src/main/java/org/kie/kogito/internal/utils/CaseInsensitiveSet.java
b/api/kogito-api/src/main/java/org/kie/kogito/internal/utils/CaseInsensitiveSet.java
new file mode 100644
index 0000000000..5bad447776
--- /dev/null
+++
b/api/kogito-api/src/main/java/org/kie/kogito/internal/utils/CaseInsensitiveSet.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.internal.utils;
+
+import java.util.TreeSet;
+
+public class CaseInsensitiveSet extends TreeSet<String> {
+
+ private static final long serialVersionUID = 1L;
+
+ public CaseInsensitiveSet(String... initialContent) {
+ // default TreeSet case insensitive comparator does not support null,
therefore using a custom one
+ super((o1, o2) -> {
+ if (o1 == null) {
+ if (o2 == null) {
+ return 0;
+ } else {
+ return -1;
+ }
+ } else if (o2 == null) {
+ return 1;
+ }
+ return String.CASE_INSENSITIVE_ORDER.compare(o1, o2);
+
+ });
+ for (String item : initialContent) {
+ add(item);
+ }
+ }
+}
diff --git
a/api/kogito-api/src/test/java/org/kie/kogito/internal/utils/CaseInsensitiveSetTest.java
b/api/kogito-api/src/test/java/org/kie/kogito/internal/utils/CaseInsensitiveSetTest.java
new file mode 100644
index 0000000000..27e22e0633
--- /dev/null
+++
b/api/kogito-api/src/test/java/org/kie/kogito/internal/utils/CaseInsensitiveSetTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.internal.utils;
+
+import java.util.Set;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class CaseInsensitiveSetTest {
+
+ @Test
+ void testCaseInsensitive() {
+ final String upperCase = "Content-Length";
+ final String lowerCase = upperCase.toLowerCase();
+ Set<String> set = new CaseInsensitiveSet(upperCase);
+ assertThat(set.contains(upperCase)).isTrue();
+ assertThat(set.add(null)).isTrue();
+ assertThat(set.add(lowerCase)).isFalse();
+ assertThat(set.add(null)).isFalse();
+ assertThat(set).hasSize(2);
+ assertThat(set.contains(lowerCase)).isTrue();
+ assertThat(set.contains(null)).isTrue();
+ assertThat(set.remove(lowerCase)).isTrue();
+ assertThat(set).hasSize(1);
+ assertThat(set.remove(null)).isTrue();
+ assertThat(set).isEmpty();
+ }
+}
diff --git
a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/org/kie/kogito/serverless/workflow/openapi/OpenApiWorkItemHandler.java
b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/org/kie/kogito/serverless/workflow/openapi/OpenApiWorkItemHandler.java
index 980c849ea4..e96274ae6f 100644
---
a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/org/kie/kogito/serverless/workflow/openapi/OpenApiWorkItemHandler.java
+++
b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/org/kie/kogito/serverless/workflow/openapi/OpenApiWorkItemHandler.java
@@ -25,7 +25,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Set;
import org.jbpm.process.instance.KogitoProcessContextImpl;
import org.jbpm.util.ContextFactory;
@@ -33,6 +32,7 @@ import org.jbpm.workflow.core.WorkflowProcess;
import org.kie.kogito.event.cloudevents.extension.ProcessMeta;
import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
import org.kie.kogito.internal.process.workitem.WorkItemExecutionException;
+import org.kie.kogito.internal.utils.CaseInsensitiveSet;
import org.kie.kogito.process.expr.ExpressionHandlerFactory;
import org.kie.kogito.serverless.workflow.SWFConstants;
import org.kie.kogito.serverless.workflow.WorkflowWorkItemHandler;
@@ -46,7 +46,7 @@ import jakarta.ws.rs.core.MultivaluedMap;
public abstract class OpenApiWorkItemHandler<T> extends
WorkflowWorkItemHandler {
- private static final Collection<String> excludedHeaders =
Set.of("User-Agent", "Host", "Content-Length", "Accept", "Accept-Encoding",
"Connection");
+ private static final Collection<String> excludedHeaders = new
CaseInsensitiveSet("User-Agent", "Host", "Content-Length", "Accept",
"Accept-Encoding", "Connection");
@Override
protected Object internalExecute(KogitoWorkItem workItem, Map<String,
Object> parameters) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]