You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ji...@apache.org on 2023/10/05 14:00:30 UTC

[camel-quarkus] 35/45: Reverted some changes of converters because of 17fb33e7498533a6eb328c7f1ea95078a3c9e68e

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

jiriondrusek pushed a commit to branch camel-main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 01bee8c155679f840d15594ae967e689a0925be6
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Fri Sep 22 15:16:02 2023 +0200

    Reverted some changes of converters because of 17fb33e7498533a6eb328c7f1ea95078a3c9e68e
---
 .../ROOT/pages/reference/extensions/core.adoc      | 12 -------
 .../quarkus/core/deployment/CamelProcessor.java    |  4 +--
 ...lContextDefaultTypeConverterStatisticsTest.java | 39 ----------------------
 .../core/runtime/src/main/doc/configuration.adoc   | 11 ------
 .../apache/camel/quarkus/core/CamelRecorder.java   |  4 +--
 .../camel/quarkus/core/FastTypeConverter.java      |  4 +--
 .../core/converter/it/ConverterResource.java       |  9 +++--
 .../src/main/resources/application.properties      |  2 --
 .../quarkus/core/converter/it/ConverterTest.java   | 29 +++++++++-------
 9 files changed, 28 insertions(+), 86 deletions(-)

diff --git a/docs/modules/ROOT/pages/reference/extensions/core.adoc b/docs/modules/ROOT/pages/reference/extensions/core.adoc
index 626220fcfe..08a263e7f8 100644
--- a/docs/modules/ROOT/pages/reference/extensions/core.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/core.adoc
@@ -123,18 +123,6 @@ camel.beans.customBeanWithSetterInjection.counter = 123
 
 As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
 
-[id="extensions-core-configuration-enabling-type-converter-statistics"]
-==== Enabling type converter statistics
-
-Set configuration property `camel.main.typeConverterStatisticsEnabled` to `true` in order to enable type converter statistics.
-[source,properties]
----
-camel.main.typeConverterStatisticsEnabled = true
----
-
-Suggested configuration from Camel `org.apache.camel.CamelContext#setTypeConverterStatisticsEnabled(Boolean)` does not have any effect on camel-quarkus.
-
-
 
 [width="100%",cols="80,5,15",options="header"]
 |===
diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java
index 19f0dc66e4..e354d2a428 100644
--- a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java
+++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java
@@ -235,9 +235,7 @@ class CamelProcessor {
 
         IndexView index = combinedIndex.getIndex();
 
-        Boolean val = CamelSupport.getOptionalConfigValue("camel.main.typeConverterStatisticsEnabled", Boolean.class, false);
-
-        RuntimeValue<TypeConverterRegistry> typeConverterRegistry = recorder.createTypeConverterRegistry(val);
+        RuntimeValue<TypeConverterRegistry> typeConverterRegistry = recorder.createTypeConverterRegistry();
 
         //
         // This should be simplified by searching for classes implementing TypeConverterLoader but that
diff --git a/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/CamelContextDefaultTypeConverterStatisticsTest.java b/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/CamelContextDefaultTypeConverterStatisticsTest.java
deleted file mode 100644
index b691e816d3..0000000000
--- a/extensions-core/core/deployment/src/test/java/org/apache/camel/quarkus/core/deployment/CamelContextDefaultTypeConverterStatisticsTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.apache.camel.quarkus.core.deployment;
-
-import io.quarkus.test.QuarkusUnitTest;
-import jakarta.inject.Inject;
-import org.apache.camel.CamelContext;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CamelContextDefaultTypeConverterStatisticsTest {
-    @RegisterExtension
-    static final QuarkusUnitTest CONFIG = new QuarkusUnitTest();
-
-    @Inject
-    CamelContext camelContext;
-
-    @Test
-    public void testDefaultTypeConverterStatistics() {
-        assertThat(camelContext.getTypeConverterRegistry().getStatistics().getClass().getSimpleName())
-                .isEqualTo("NoopTypeConverterStatistics");
-    }
-}
diff --git a/extensions-core/core/runtime/src/main/doc/configuration.adoc b/extensions-core/core/runtime/src/main/doc/configuration.adoc
index beba713a4a..68827731fd 100644
--- a/extensions-core/core/runtime/src/main/doc/configuration.adoc
+++ b/extensions-core/core/runtime/src/main/doc/configuration.adoc
@@ -61,14 +61,3 @@ camel.beans.customBeanWithSetterInjection.counter = 123
 ---
 
 As such, the class `PropertiesCustomBeanWithSetterInjection` needs to be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection], note that field access could be omitted in this case.
-
-==== Enabling type converter statistics
-
-Set configuration property `camel.main.typeConverterStatisticsEnabled` to `true` in order to enable type converter statistics.
-[source,properties]
----
-camel.main.typeConverterStatisticsEnabled = true
----
-
-Suggested configuration from Camel `org.apache.camel.CamelContext#setTypeConverterStatisticsEnabled(Boolean)` does not have any effect on camel-quarkus.
-
diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java
index d20bf5aeae..20f51df4af 100644
--- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java
+++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java
@@ -66,8 +66,8 @@ public class CamelRecorder {
         return new RuntimeValue<>(new RuntimeRegistry(beanQualifierResolvers));
     }
 
-    public RuntimeValue<TypeConverterRegistry> createTypeConverterRegistry(boolean typeConvertersatisticsEnabled) {
-        return new RuntimeValue<>(new FastTypeConverter(typeConvertersatisticsEnabled));
+    public RuntimeValue<TypeConverterRegistry> createTypeConverterRegistry() {
+        return new RuntimeValue<>(new FastTypeConverter());
     }
 
     public void addTypeConverterLoader(RuntimeValue<TypeConverterRegistry> registry, RuntimeValue<TypeConverterLoader> loader) {
diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastTypeConverter.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastTypeConverter.java
index 41aee346eb..f4587dc151 100644
--- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastTypeConverter.java
+++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/FastTypeConverter.java
@@ -24,8 +24,8 @@ import org.slf4j.LoggerFactory;
 public class FastTypeConverter extends DefaultTypeConverter {
     private static final Logger LOG = LoggerFactory.getLogger(FastTypeConverter.class);
 
-    public FastTypeConverter(boolean typeConvertersatisticsEnabled) {
-        super(null, null, null, true, typeConvertersatisticsEnabled);
+    public FastTypeConverter() {
+        super(null, null, null, false);
     }
 
     @Override
diff --git a/integration-test-groups/foundation/type-converter/src/main/java/org/apache/camel/quarkus/core/converter/it/ConverterResource.java b/integration-test-groups/foundation/type-converter/src/main/java/org/apache/camel/quarkus/core/converter/it/ConverterResource.java
index 7bbd00a44f..d6c19940eb 100644
--- a/integration-test-groups/foundation/type-converter/src/main/java/org/apache/camel/quarkus/core/converter/it/ConverterResource.java
+++ b/integration-test-groups/foundation/type-converter/src/main/java/org/apache/camel/quarkus/core/converter/it/ConverterResource.java
@@ -90,11 +90,14 @@ public class ConverterResource {
         return context.getTypeConverter().convertTo(MyNullablePair.class, input);
     }
 
-    @Path("/resetStatistics")
+    @Path("/setStatisticsEnabled")
     @POST
     @Produces(MediaType.TEXT_PLAIN)
-    public void converterResetStatistics() {
-        context.getTypeConverterRegistry().getStatistics().reset();
+    public void cnverterSetStatisticsEnabled(boolean value) {
+        context.getTypeConverterRegistry().getStatistics().setStatisticsEnabled(value);
+        if (value) {
+            context.getTypeConverterRegistry().getStatistics().reset();
+        }
     }
 
     @Path("/getStatisticsHit")
diff --git a/integration-test-groups/foundation/type-converter/src/main/resources/application.properties b/integration-test-groups/foundation/type-converter/src/main/resources/application.properties
index 871983a1f6..b6ff2229d0 100644
--- a/integration-test-groups/foundation/type-converter/src/main/resources/application.properties
+++ b/integration-test-groups/foundation/type-converter/src/main/resources/application.properties
@@ -16,5 +16,3 @@
 ## ---------------------------------------------------------------------------
 quarkus.log.file.enable = true
 quarkus.log.file.path = target/quarkus.log
-
-camel.main.typeConverterStatisticsEnabled = true
\ No newline at end of file
diff --git a/integration-test-groups/foundation/type-converter/src/test/java/org/apache/camel/quarkus/core/converter/it/ConverterTest.java b/integration-test-groups/foundation/type-converter/src/test/java/org/apache/camel/quarkus/core/converter/it/ConverterTest.java
index 30083cf0e5..d7d3c3edf1 100644
--- a/integration-test-groups/foundation/type-converter/src/test/java/org/apache/camel/quarkus/core/converter/it/ConverterTest.java
+++ b/integration-test-groups/foundation/type-converter/src/test/java/org/apache/camel/quarkus/core/converter/it/ConverterTest.java
@@ -42,20 +42,24 @@ public class ConverterTest {
 
     @Test
     void testConverterToNull() {
-        resetStatistics();
+        enableStatistics(true);
 
         testConverterReturningNull("/converter/myNullablePair", "null");
 
         RestAssured.when().get("/converter/getStatisticsHit").then().body("hit", is(1), "miss", is(0));
+
+        enableStatistics(false);
     }
 
     @Test
     void testNotRegisteredConverter() {
-        resetStatistics();
+        enableStatistics(true);
 
         testConverterReturningNull("/converter/myNotRegisteredPair", "a:b");
 
         RestAssured.when().get("/converter/getStatisticsHit").then().body("hit", is(0), "miss", is(1));
+
+        enableStatistics(false);
     }
 
     @Test
@@ -83,12 +87,22 @@ public class ConverterTest {
 
     @Test
     void testConverterGetStatistics() {
-        resetStatistics();
+        enableStatistics(true);
 
         //cause 1 hit
         testConverterFromAnnotation();
 
         RestAssured.when().get("/converter/getStatisticsHit").then().body("hit", is(1), "miss", is(0));
+
+        enableStatistics(false);
+    }
+
+    private void enableStatistics(boolean b) {
+        RestAssured.given()
+                .contentType(ContentType.TEXT).body(b)
+                .post("/converter/setStatisticsEnabled")
+                .then()
+                .statusCode(204);
     }
 
     private void testConverterReturningNull(String url, String body) {
@@ -111,13 +125,4 @@ public class ConverterTest {
             response.body("key", is(expectedKey), "val", is(expectedValue));
         }
     }
-
-    private void resetStatistics() {
-        //reset statistics
-        RestAssured.given()
-                .contentType(ContentType.TEXT)
-                .post("/converter/resetStatistics")
-                .then()
-                .statusCode(204);
-    }
 }