You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/04/02 09:40:06 UTC

[camel] branch main updated: optimized map iteration: entrySet() and enhanced 'for' loop instead of keySet() (#9754)

This is an automated email from the ASF dual-hosted git repository.

davsclaus 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 15c50cd3816 optimized map iteration: entrySet() and enhanced 'for' loop instead of keySet() (#9754)
15c50cd3816 is described below

commit 15c50cd3816f366f02fde18ad6895688ec0cf750
Author: dk2k <dk...@users.noreply.github.com>
AuthorDate: Sun Apr 2 12:39:59 2023 +0300

    optimized map iteration: entrySet() and enhanced 'for' loop instead of keySet() (#9754)
    
    Co-authored-by: dk2k <dk...@ya.ru>
---
 .../camel/component/aws/xray/FakeAWSDaemon.java    |  6 +++---
 .../camel/component/aws/xray/TestDataBuilder.java  | 12 ++++++------
 .../apache/camel/component/aws/xray/TestUtils.java | 15 ++++++++-------
 .../caffeine/cache/CaffeineCacheProducerTest.java  |  5 ++---
 .../loadcache/CaffeineLoadCacheProducerTest.java   |  6 ++----
 ...MarshalHeaderWithCustomMarshallFactoryTest.java |  4 ++--
 .../github/services/MockPullRequestService.java    |  3 +--
 .../storage/localstorage/FakeStorageRpc.java       | 22 ++++++++++++----------
 .../camel/component/jetty/HttpsAsyncRouteTest.java |  5 +++--
 .../camel/component/jetty/HttpsRouteTest.java      |  5 +++--
 .../component/jetty/SpringHttpsRouteTest.java      |  5 +++--
 .../org/apache/camel/jsonpath/JsonPathEngine.java  | 10 +++++-----
 .../cluster/KubernetesClusterServiceTest.java      |  6 +++---
 .../multipart/MimeMultipartDataFormatTest.java     |  8 ++++----
 .../component/netty/http/NettyHttpSSLTest.java     |  6 ++++--
 .../component/vertx/http/VertxHttpProducer.java    |  2 +-
 16 files changed, 62 insertions(+), 58 deletions(-)

diff --git a/components/camel-aws/camel-aws-xray/src/test/java/org/apache/camel/component/aws/xray/FakeAWSDaemon.java b/components/camel-aws/camel-aws-xray/src/test/java/org/apache/camel/component/aws/xray/FakeAWSDaemon.java
index 37efb1d91af..24be19d6a6f 100644
--- a/components/camel-aws/camel-aws-xray/src/test/java/org/apache/camel/component/aws/xray/FakeAWSDaemon.java
+++ b/components/camel-aws/camel-aws-xray/src/test/java/org/apache/camel/component/aws/xray/FakeAWSDaemon.java
@@ -202,9 +202,9 @@ public class FakeAWSDaemon {
             if (json.has("metadata")) {
                 JsonObject rawMetadata = (JsonObject) json.get("metadata");
                 Map<String, Map<String, Object>> metadata = parseMetadata(rawMetadata);
-                for (String namespace : metadata.keySet()) {
-                    for (String key : metadata.get(namespace).keySet()) {
-                        entity.withMetadata(namespace, key, metadata.get(namespace).get(key));
+                for (Map.Entry<String, Map<String, Object>> entry : metadata.entrySet()) {
+                    for (String key : entry.getValue().keySet()) {
+                        entity.withMetadata(entry.getKey(), key, entry.getValue().get(key));
                     }
                 }
             }
diff --git a/components/camel-aws/camel-aws-xray/src/test/java/org/apache/camel/component/aws/xray/TestDataBuilder.java b/components/camel-aws/camel-aws-xray/src/test/java/org/apache/camel/component/aws/xray/TestDataBuilder.java
index de5d4afc7ce..e4433d78924 100644
--- a/components/camel-aws/camel-aws-xray/src/test/java/org/apache/camel/component/aws/xray/TestDataBuilder.java
+++ b/components/camel-aws/camel-aws-xray/src/test/java/org/apache/camel/component/aws/xray/TestDataBuilder.java
@@ -143,28 +143,28 @@ final class TestDataBuilder {
             if (!annotations.isEmpty()) {
                 ret += ", annotations: {";
                 StringBuilder sb = new StringBuilder();
-                for (String key : annotations.keySet()) {
+                for (Map.Entry<String, Object> entry : annotations.entrySet()) {
                     if (sb.length() > 0) {
                         sb.append(", ");
                     }
-                    sb.append(key).append("->").append(annotations.get(key));
+                    sb.append(entry.getKey()).append("->").append(entry.getValue());
                 }
                 ret += sb.toString() + "}";
             }
             if (!metadata.isEmpty()) {
                 ret += ", metadata: {";
                 StringBuilder sb = new StringBuilder();
-                for (String namespace : metadata.keySet()) {
+                for (Map.Entry<String, Map<String, Object>> entry : metadata.entrySet()) {
                     if (sb.length() > 0) {
                         sb.append(", ");
                     }
-                    sb.append(namespace).append(": [");
+                    sb.append(entry.getKey()).append(": [");
                     boolean first = true;
-                    for (String key : metadata.get(namespace).keySet()) {
+                    for (String key : entry.getValue().keySet()) {
                         if (!first) {
                             sb.append(", ");
                         }
-                        sb.append(key).append("->").append(metadata.get(namespace).get(key));
+                        sb.append(key).append("->").append(entry.getValue().get(key));
                         first = false;
                     }
                     sb.append("]");
diff --git a/components/camel-aws/camel-aws-xray/src/test/java/org/apache/camel/component/aws/xray/TestUtils.java b/components/camel-aws/camel-aws-xray/src/test/java/org/apache/camel/component/aws/xray/TestUtils.java
index d034a5eb4ab..1e266d2186c 100644
--- a/components/camel-aws/camel-aws-xray/src/test/java/org/apache/camel/component/aws/xray/TestUtils.java
+++ b/components/camel-aws/camel-aws-xray/src/test/java/org/apache/camel/component/aws/xray/TestUtils.java
@@ -42,8 +42,7 @@ public final class TestUtils {
         assertThat("Incorrect number of traces",
                 receivedData.size(), is(equalTo(testData.size())));
         int i = 0;
-        for (String key : receivedData.keySet()) {
-            TestTrace trace = receivedData.get(key);
+        for (TestTrace trace : receivedData.values()) {
             verifyTraces(testData.get(i++), trace);
         }
     }
@@ -149,10 +148,11 @@ public final class TestUtils {
 
     private static void verifyAnnotations(Map<String, Object> expected, Map<String, Object> actual) {
         assertThat(actual.size(), is(equalTo(expected.size())));
-        for (String key : expected.keySet()) {
+        for (Map.Entry<String, Object> entry : expected.entrySet()) {
+            String key = entry.getKey();
             assertTrue(actual.containsKey(key), "Annotation " + key + " is missing");
             assertThat("Annotation value of " + key + " is different",
-                    actual.get(key), is(equalTo(expected.get(key))));
+                    actual.get(key), is(equalTo(entry.getValue())));
         }
     }
 
@@ -162,14 +162,15 @@ public final class TestUtils {
 
         assertThat("Insufficient number of metadata found",
                 actual.size(), is(greaterThanOrEqualTo(expected.size())));
-        for (String namespace : expected.keySet()) {
+        for (Map.Entry<String, Map<String, Object>> entry : expected.entrySet()) {
+            String namespace = entry.getKey();
             assertTrue(actual.containsKey(namespace),
                     "Namespace " + namespace + " not found in metadata");
-            for (String key : expected.get(namespace).keySet()) {
+            for (String key : entry.getValue().keySet()) {
                 assertTrue(actual.get(namespace).containsKey(key),
                         "Key " + key + " of namespace + " + namespace + " not found");
                 assertThat("Incorrect value of key " + key + " in namespace " + namespace,
-                        actual.get(namespace).get(key), is(equalTo(expected.get(namespace).get(key))));
+                        actual.get(namespace).get(key), is(equalTo(entry.getValue().get(key))));
             }
         }
     }
diff --git a/components/camel-caffeine/src/test/java/org/apache/camel/component/caffeine/cache/CaffeineCacheProducerTest.java b/components/camel-caffeine/src/test/java/org/apache/camel/component/caffeine/cache/CaffeineCacheProducerTest.java
index ae5134f2cba..f225f45bbc3 100644
--- a/components/camel-caffeine/src/test/java/org/apache/camel/component/caffeine/cache/CaffeineCacheProducerTest.java
+++ b/components/camel-caffeine/src/test/java/org/apache/camel/component/caffeine/cache/CaffeineCacheProducerTest.java
@@ -218,7 +218,6 @@ public class CaffeineCacheProducerTest extends CaffeineCacheTestSupport {
     void testCacheAsMap() throws Exception {
         final Cache<Object, Object> cache = getTestCache();
         final Map<String, String> map = generateRandomMapOfString(3);
-        final Set<String> keys = map.keySet();
 
         cache.putAll(map);
 
@@ -233,9 +232,9 @@ public class CaffeineCacheProducerTest extends CaffeineCacheTestSupport {
         MockEndpoint.assertIsSatisfied(context);
 
         final Map<String, String> elements = exchange.getMessage().getBody(Map.class);
-        keys.forEach(k -> {
+        map.forEach((k, s) -> {
             assertTrue(elements.containsKey(k));
-            assertEquals(map.get(k), elements.get(k));
+            assertEquals(s, elements.get(k));
         });
     }
 
diff --git a/components/camel-caffeine/src/test/java/org/apache/camel/component/caffeine/loadcache/CaffeineLoadCacheProducerTest.java b/components/camel-caffeine/src/test/java/org/apache/camel/component/caffeine/loadcache/CaffeineLoadCacheProducerTest.java
index 617e81d13c4..3eaec343f52 100644
--- a/components/camel-caffeine/src/test/java/org/apache/camel/component/caffeine/loadcache/CaffeineLoadCacheProducerTest.java
+++ b/components/camel-caffeine/src/test/java/org/apache/camel/component/caffeine/loadcache/CaffeineLoadCacheProducerTest.java
@@ -233,8 +233,6 @@ public class CaffeineLoadCacheProducerTest extends CaffeineLoadCacheTestSupport
         map.put("B", "BB");
         map.put("C", "CC");
 
-        final Set<String> keys = map.keySet();
-
         cache.putAll(map);
 
         final MockEndpoint mock = getMockEndpoint("mock:result");
@@ -248,9 +246,9 @@ public class CaffeineLoadCacheProducerTest extends CaffeineLoadCacheTestSupport
         MockEndpoint.assertIsSatisfied(context);
 
         final Map<String, String> elements = exchange.getMessage().getBody(Map.class);
-        keys.forEach(k -> {
+        map.forEach((k, s) -> {
             assertTrue(elements.containsKey(k));
-            assertEquals(map.get(k), elements.get(k));
+            assertEquals(s, elements.get(k));
         });
     }
 
diff --git a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvMarshalHeaderWithCustomMarshallFactoryTest.java b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvMarshalHeaderWithCustomMarshallFactoryTest.java
index 8f46dfd72c5..1a8033adae6 100644
--- a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvMarshalHeaderWithCustomMarshallFactoryTest.java
+++ b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvMarshalHeaderWithCustomMarshallFactoryTest.java
@@ -156,8 +156,8 @@ public class CsvMarshalHeaderWithCustomMarshallFactoryTest extends CamelTestSupp
         @Override
         protected Iterable<?> getMapRecordValues(Map<?, ?> map) {
             List<String> result = new ArrayList<>(map.size());
-            for (Object key : map.keySet()) {
-                result.add((String) map.get(key));
+            for (Object o : map.values()) {
+                result.add((String) o);
             }
             return result;
         }
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/services/MockPullRequestService.java b/components/camel-github/src/test/java/org/apache/camel/component/github/services/MockPullRequestService.java
index af06c0eddf5..6f77abb5eb4 100644
--- a/components/camel-github/src/test/java/org/apache/camel/component/github/services/MockPullRequestService.java
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/services/MockPullRequestService.java
@@ -115,8 +115,7 @@ public class MockPullRequestService extends PullRequestService {
     public synchronized List<PullRequest> getPullRequests(IRepositoryIdProvider repository, String state) {
         List<PullRequest> result = new ArrayList<>();
 
-        for (Long id : pullRequests.keySet()) {
-            PullRequest pr = pullRequests.get(id);
+        for (PullRequest pr : pullRequests.values()) {
             if (pr.getState().equals(state)) {
                 result.add(pr);
             }
diff --git a/components/camel-google/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/localstorage/FakeStorageRpc.java b/components/camel-google/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/localstorage/FakeStorageRpc.java
index 53f518b2315..2132dcda49e 100644
--- a/components/camel-google/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/localstorage/FakeStorageRpc.java
+++ b/components/camel-google/camel-google-storage/src/test/java/org/apache/camel/component/google/storage/localstorage/FakeStorageRpc.java
@@ -314,9 +314,10 @@ class FakeStorageRpc extends StorageRpcTestBase {
             throws StorageException {
         // if non-null, then we check the file's at that generation.
         Long generationMatch = null;
-        for (Option op : options.keySet()) {
+        for (Map.Entry<Option, ?> entry : options.entrySet()) {
+            Option op = entry.getKey();
             if (op.equals(StorageRpc.Option.IF_GENERATION_MATCH)) {
-                generationMatch = (Long) options.get(op);
+                generationMatch = (Long) entry.getValue();
             } else {
                 throw new UnsupportedOperationException("Unknown option: " + op);
             }
@@ -349,9 +350,10 @@ class FakeStorageRpc extends StorageRpcTestBase {
             StorageObject from, Map<Option, ?> options, long position, OutputStream outputStream) {
         // if non-null, then we check the file's at that generation.
         Long generationMatch = null;
-        for (Option op : options.keySet()) {
+        for (Map.Entry<Option, ?> entry : options.entrySet()) {
+            Option op = entry.getKey();
             if (op.equals(StorageRpc.Option.IF_GENERATION_MATCH)) {
-                generationMatch = (Long) options.get(op);
+                generationMatch = (Long) entry.getValue();
             } else {
                 throw new UnsupportedOperationException("Unknown option: " + op);
             }
@@ -383,10 +385,10 @@ class FakeStorageRpc extends StorageRpcTestBase {
         String key = fullname(object);
         // if non-null, then we check the file's at that generation.
         Long generationMatch = null;
-        for (Option option : options.keySet()) {
+        for (Map.Entry<Option, ?> entry : options.entrySet()) {
             // this is a bit of a hack, since we don't implement generations.
-            if (option == Option.IF_GENERATION_MATCH) {
-                generationMatch = (Long) options.get(option);
+            if (entry.getKey() == Option.IF_GENERATION_MATCH) {
+                generationMatch = (Long) entry.getValue();
             }
         }
         checkGeneration(key, generationMatch);
@@ -460,10 +462,10 @@ class FakeStorageRpc extends StorageRpcTestBase {
 
         // if non-null, then we check the file's at that generation.
         Long generationMatch = null;
-        for (Option option : rewriteRequest.targetOptions.keySet()) {
+        for (Map.Entry<Option, ?> entry : rewriteRequest.targetOptions.entrySet()) {
             // this is a bit of a hack, since we don't implement generations.
-            if (option == Option.IF_GENERATION_MATCH) {
-                generationMatch = (Long) rewriteRequest.targetOptions.get(option);
+            if (entry.getKey() == Option.IF_GENERATION_MATCH) {
+                generationMatch = (Long) entry.getValue();
             }
         }
 
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java
index 03f5860cd84..7df52a7edcb 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java
@@ -82,8 +82,9 @@ public class HttpsAsyncRouteTest extends HttpsRouteTest {
 
     @Override
     protected void restoreSystemProperties() {
-        for (Object key : originalValues.keySet()) {
-            Object value = originalValues.get(key);
+        for (Map.Entry<Object, Object> entry : originalValues.entrySet()) {
+            Object key = entry.getKey();
+            Object value = entry.getValue();
             if (NULL_VALUE_MARKER.equals(value)) {
                 System.clearProperty((String) key);
             } else {
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java
index 6f9b5ece787..c6effeff54f 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java
@@ -105,8 +105,9 @@ public class HttpsRouteTest extends BaseJettyTest {
     }
 
     protected void restoreSystemProperties() {
-        for (Object key : originalValues.keySet()) {
-            Object value = originalValues.get(key);
+        for (Map.Entry<Object, Object> entry : originalValues.entrySet()) {
+            Object key = entry.getKey();
+            Object value = entry.getValue();
             if (NULL_VALUE_MARKER.equals(value)) {
                 System.clearProperty((String) key);
             } else {
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
index c0b82af32c5..38b21d8d9ce 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/SpringHttpsRouteTest.java
@@ -86,8 +86,9 @@ public class SpringHttpsRouteTest {
     }
 
     private void restoreSystemProperties() {
-        for (Object key : originalValues.keySet()) {
-            Object value = originalValues.get(key);
+        for (Map.Entry<Object, Object> entry : originalValues.entrySet()) {
+            Object key = entry.getKey();
+            Object value = entry.getValue();
             if (NULL_VALUE_MARKER.equals(value)) {
                 System.clearProperty((String) key);
             } else {
diff --git a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java
index 597014fc751..b3e4c2acc5b 100644
--- a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java
+++ b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java
@@ -139,7 +139,7 @@ public class JsonPathEngine {
             // write each row as a string but keep it as a list/iterable
             if (answer instanceof Iterable) {
                 List<String> list = new ArrayList<>();
-                Iterable it = (Iterable) answer;
+                Iterable<Object> it = (Iterable<Object>) answer;
                 for (Object o : it) {
                     if (adapter != null) {
                         String json = adapter.writeAsString(o, exchange);
@@ -150,13 +150,13 @@ public class JsonPathEngine {
                 }
                 return list;
             } else if (answer instanceof Map) {
-                Map map = (Map) answer;
-                for (Object key : map.keySet()) {
-                    Object value = map.get(key);
+                Map<Object, Object> map = (Map<Object, Object>) answer;
+                for (Map.Entry<Object, Object> entry : map.entrySet()) {
+                    Object value = entry.getValue();
                     if (adapter != null) {
                         String json = adapter.writeAsString(value, exchange);
                         if (json != null) {
-                            map.put(key, json);
+                            map.put(entry.getKey(), json);
                         }
                     }
                 }
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/cluster/KubernetesClusterServiceTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/cluster/KubernetesClusterServiceTest.java
index 13c289a5fe6..4306c181004 100644
--- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/cluster/KubernetesClusterServiceTest.java
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/cluster/KubernetesClusterServiceTest.java
@@ -312,9 +312,9 @@ public class KubernetesClusterServiceTest extends CamelTestSupport {
             Predicate<Map<String, String>> condition, long time, TimeUnit unit) {
         Awaitility.waitAtMost(time, unit).until(() -> {
             Map<String, String> leaders = new HashMap<>();
-            for (String partition : partitionRecorders.keySet()) {
+            for (Map.Entry<String, List<LeaderRecorder>> entry : partitionRecorders.entrySet()) {
                 String leader = null;
-                for (LeaderRecorder recorder : partitionRecorders.get(partition)) {
+                for (LeaderRecorder recorder : entry.getValue()) {
                     String partitionLeader = recorder.getCurrentLeader();
                     if (partitionLeader == null || isCurrentLeader(leader, partitionLeader)) {
                         return false;
@@ -324,7 +324,7 @@ public class KubernetesClusterServiceTest extends CamelTestSupport {
                 if (leader == null) {
                     return false;
                 }
-                leaders.put(partition, leader);
+                leaders.put(entry.getKey(), leader);
             }
             return condition.test(leaders);
         });
diff --git a/components/camel-mail/src/test/java/org/apache/camel/dataformat/mime/multipart/MimeMultipartDataFormatTest.java b/components/camel-mail/src/test/java/org/apache/camel/dataformat/mime/multipart/MimeMultipartDataFormatTest.java
index 9e56de3d480..3bc4786ce7f 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/dataformat/mime/multipart/MimeMultipartDataFormatTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/dataformat/mime/multipart/MimeMultipartDataFormatTest.java
@@ -516,8 +516,8 @@ public class MimeMultipartDataFormatTest extends CamelTestSupport {
     private void addAttachment(DataSource ds, String attFileName, Map<String, String> headers) {
         DefaultAttachment attachment = new DefaultAttachment(ds);
         if (headers != null) {
-            for (String headerName : headers.keySet()) {
-                attachment.addHeader(headerName, headers.get(headerName));
+            for (Map.Entry<String, String> entry : headers.entrySet()) {
+                attachment.addHeader(entry.getKey(), entry.getValue());
             }
         }
         in.addAttachmentObject(attFileName, attachment);
@@ -532,8 +532,8 @@ public class MimeMultipartDataFormatTest extends CamelTestSupport {
         DataSource ds = new ByteArrayDataSource(attText, attContentType);
         DefaultAttachment attachment = new DefaultAttachment(ds);
         if (headers != null) {
-            for (String headerName : headers.keySet()) {
-                attachment.addHeader(headerName, headers.get(headerName));
+            for (Map.Entry<String, String> entry : headers.entrySet()) {
+                attachment.addHeader(entry.getKey(), entry.getValue());
             }
         }
         in.addAttachmentObject(attFileName, attachment);
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSSLTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSSLTest.java
index 0def4d8086d..890d464b728 100644
--- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSSLTest.java
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSSLTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.netty.http;
 
 import java.net.URL;
+import java.util.Map;
 import java.util.Properties;
 
 import javax.net.ssl.SSLSession;
@@ -64,8 +65,9 @@ public class NettyHttpSSLTest extends BaseNettyTest {
     }
 
     protected void restoreSystemProperties() {
-        for (Object key : originalValues.keySet()) {
-            Object value = originalValues.get(key);
+        for (Map.Entry<Object, Object> entry : originalValues.entrySet()) {
+            Object key = entry.getKey();
+            Object value = entry.getValue();
             if (NULL_VALUE_MARKER.equals(value)) {
                 System.clearProperty((String) key);
             } else {
diff --git a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpProducer.java b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpProducer.java
index 24666591628..3d227e7b777 100644
--- a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpProducer.java
+++ b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpProducer.java
@@ -84,7 +84,7 @@ public class VertxHttpProducer extends DefaultAsyncProducer {
                     if (CONTENT_TYPE_FORM_URLENCODED.equals(contentType)) {
                         MultiMap map = MultiMap.caseInsensitiveMultiMap();
                         Map<String, Object> formParams = URISupport.parseQuery((String) body);
-                        formParams.keySet().forEach(key -> map.add(key, String.valueOf(formParams.get(key))));
+                        formParams.forEach((key, o) -> map.add(key, String.valueOf(o)));
                         request.sendForm(map, resultHandler);
                     } else {
                         // Fallback to send as Buffer