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/03 07:42:59 UTC
[camel] branch main updated: fixed non-functional usage of Optional.isPresent() (#9765)
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 e9975891260 fixed non-functional usage of Optional.isPresent() (#9765)
e9975891260 is described below
commit e997589126015ad5c9d31df624cac214aa5abe98
Author: dk2k <dk...@users.noreply.github.com>
AuthorDate: Mon Apr 3 10:42:52 2023 +0300
fixed non-functional usage of Optional.isPresent() (#9765)
Co-authored-by: dk2k <dk...@ya.ru>
---
.../org/apache/camel/component/splunk/support/TcpDataWriter.java | 2 +-
.../main/java/org/apache/camel/impl/engine/SimpleCamelContext.java | 6 +-----
.../test/java/org/apache/camel/CamelParallelExecutionStrategy.java | 4 ++--
3 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/support/TcpDataWriter.java b/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/support/TcpDataWriter.java
index f1878ef60f9..f60f7228f62 100644
--- a/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/support/TcpDataWriter.java
+++ b/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/support/TcpDataWriter.java
@@ -48,7 +48,7 @@ public class TcpDataWriter extends SplunkDataWriter {
@Override
protected Socket createSocket(Service service) throws IOException {
- int p = localPort.isPresent() ? localPort.get() : port;
+ int p = localPort.orElseGet(() -> port);
TcpInput input = (TcpInput) service.getInputs().get(String.valueOf(p));
if (input == null) {
throw new RuntimeException("no input defined for port " + port);
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SimpleCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SimpleCamelContext.java
index cf3b57f29b6..d7d35a4b113 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SimpleCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SimpleCamelContext.java
@@ -183,11 +183,7 @@ public class SimpleCamelContext extends AbstractCamelContext {
protected Injector createInjector() {
FactoryFinder finder = getBootstrapFactoryFinder();
Optional<Injector> result = finder.newInstance("Injector", Injector.class);
- if (result.isPresent()) {
- return result.get();
- } else {
- return new DefaultInjector(getCamelContextReference());
- }
+ return result.orElseGet(() -> new DefaultInjector(getCamelContextReference()));
}
@Override
diff --git a/core/camel-core/src/test/java/org/apache/camel/CamelParallelExecutionStrategy.java b/core/camel-core/src/test/java/org/apache/camel/CamelParallelExecutionStrategy.java
index 8dd28da24c5..a5ed6e32d08 100644
--- a/core/camel-core/src/test/java/org/apache/camel/CamelParallelExecutionStrategy.java
+++ b/core/camel-core/src/test/java/org/apache/camel/CamelParallelExecutionStrategy.java
@@ -85,10 +85,10 @@ public class CamelParallelExecutionStrategy implements ParallelExecutionConfigur
public ParallelExecutionConfiguration createConfiguration(ConfigurationParameters configurationParameters) {
Optional<Integer> parallelism = configurationParameters.get(CONFIG_CUSTOM_PARALLELISM_PROPERTY_NAME,
Integer::valueOf);
- this.nbParallelExecutions = parallelism.isPresent() ? parallelism.get() : DEFAULT_PARALLELISM;
+ this.nbParallelExecutions = parallelism.orElse(DEFAULT_PARALLELISM);
Optional<Integer> poolSize = configurationParameters.get(CONFIG_CUSTOM_MAXPOOLSIZE_PROPERTY_NAME,
Integer::valueOf);
- this.maxPoolSize = poolSize.isPresent() ? poolSize.get() : nbParallelExecutions * 256;
+ this.maxPoolSize = poolSize.orElseGet(() -> nbParallelExecutions * 256);
LOG.info(String.format("Using custom JUnit parallel execution with parallelism=%d and maxPoolSize=%d",
nbParallelExecutions, maxPoolSize));