Repository: helidon-io/helidon (java)

Issue:
Upgrade to mysql-connector-j 8.2.0 or newer
Upgrade to mysql-connector-j 8.2.0 or newer. Need to do this in:

- [x] 2.x
- [x] 3.x
- [x] 4.x #7988



Pull request:
[4.x] Upgrade to mysql-connector-j 8.2.0
Fixes #7926 in 4.x

Patch:
diff --git a/archetypes/helidon/src/main/archetype/mp/custom/database-outputs.xml b/archetypes/helidon/src/main/archetype/mp/custom/database-outputs.xml
index 9c9d3e09e2..f89aabfe3d 100644
--- a/archetypes/helidon/src/main/archetype/mp/custom/database-outputs.xml
+++ b/archetypes/helidon/src/main/archetype/mp/custom/database-outputs.xml
@@ -306,8 +306,8 @@ docker run --rm --name mysql -p 3306:3306 \
                     </list>
                     <list key="dependencies">
                         <map>
-                            <value key="groupId">mysql</value>
-                            <value key="artifactId">mysql-connector-java</value>
+                            <value key="groupId">com.mysql</value>
+                            <value key="artifactId">mysql-connector-j</value>
                             <value key="scope">runtime</value>
                         </map>
                     </list>
diff --git a/archetypes/helidon/src/main/archetype/se/custom/database-output.xml b/archetypes/helidon/src/main/archetype/se/custom/database-output.xml
index 7d0b7622a4..5e4135c609 100644
--- a/archetypes/helidon/src/main/archetype/se/custom/database-output.xml
+++ b/archetypes/helidon/src/main/archetype/se/custom/database-output.xml
@@ -61,8 +61,8 @@ For details, see https://www.h2database.com/html/cheatSheet.html
                             <value key="artifactId">helidon-integrations-db-mysql</value>
                         </map>
                         <map>
-                            <value key="groupId">mysql</value>
-                            <value key="artifactId">mysql-connector-java</value>
+                            <value key="groupId">com.mysql</value>
+                            <value key="artifactId">mysql-connector-j</value>
                         </map>
                     </list>
                     <value key="db-health-check-stmt" if="${health}">SELECT 0</value>
diff --git a/common/socket/src/main/java/io/helidon/common/socket/SocketOptionsBlueprint.java b/common/socket/src/main/java/io/helidon/common/socket/SocketOptionsBlueprint.java
index c487c778a2..4fc8d864eb 100644
--- a/common/socket/src/main/java/io/helidon/common/socket/SocketOptionsBlueprint.java
+++ b/common/socket/src/main/java/io/helidon/common/socket/SocketOptionsBlueprint.java
@@ -23,6 +23,7 @@ import java.net.SocketOption;
 import java.net.StandardSocketOptions;
 import java.time.Duration;
 import java.util.Map;
+import java.util.Optional;
 
 import io.helidon.builder.api.Option;
 import io.helidon.builder.api.Prototype;
@@ -67,8 +68,8 @@ interface SocketOptionsBlueprint {
      * @return buffer size, in bytes
      * @see java.net.StandardSocketOptions#SO_RCVBUF
      */
-    @ConfiguredOption("32768")
-    int socketReceiveBufferSize();
+    @ConfiguredOption
+    Optional<Integer> socketReceiveBufferSize();
 
     /**
      * Socket send buffer size.
@@ -76,8 +77,8 @@ interface SocketOptionsBlueprint {
      * @return buffer size, in bytes
      * @see java.net.StandardSocketOptions#SO_SNDBUF
      */
-    @ConfiguredOption("32768")
-    int socketSendBufferSize();
+    @ConfiguredOption
+    Optional<Integer> socketSendBufferSize();
 
     /**
      * Socket reuse address.
@@ -129,8 +130,8 @@ interface SocketOptionsBlueprint {
     class BuilderDecorator implements Prototype.BuilderDecorator<SocketOptions.BuilderBase<?, ?>> {
         @Override
         public void decorate(SocketOptions.BuilderBase<?, ?> target) {
-            target.putSocketOption(StandardSocketOptions.SO_RCVBUF, target.socketReceiveBufferSize());
-            target.putSocketOption(StandardSocketOptions.SO_SNDBUF, target.socketSendBufferSize());
+            target.socketReceiveBufferSize().ifPresent(i -> target.putSocketOption(StandardSocketOptions.SO_RCVBUF, i));
+            target.socketSendBufferSize().ifPresent(i -> target.putSocketOption(StandardSocketOptions.SO_SNDBUF, i));
             target.putSocketOption(StandardSocketOptions.SO_REUSEADDR, target.socketReuseAddress());
             target.putSocketOption(StandardSocketOptions.SO_KEEPALIVE, target.socketKeepAlive());
             target.putSocketOption(StandardSocketOptions.TCP_NODELAY, target.tcpNoDelay());
diff --git a/dependencies/pom.xml b/dependencies/pom.xml
index b428a54bab..7023bf6356 100644
--- a/dependencies/pom.xml
+++ b/dependencies/pom.xml
@@ -121,7 +121,7 @@
         <version.lib.microstream>08.01.01-MS-GA</version.lib.microstream>
         <version.lib.mongodb>4.10.2</version.lib.mongodb>
         <version.lib.mssql-jdbc>8.4.1.jre8</version.lib.mssql-jdbc>
-        <version.lib.mysql-connector-java>8.0.28</version.lib.mysql-connector-java>
+        <version.lib.mysql-connector-j>8.2.0</version.lib.mysql-connector-j>
         <version.lib.narayana>7.0.0.Final</version.lib.narayana>
         <version.lib.neo4j>5.12.0</version.lib.neo4j>
         <version.lib.netty>4.1.100.Final</version.lib.netty>
@@ -810,9 +810,9 @@
                 <version>${version.lib.h2}</version>
             </dependency>
             <dependency>
-                <groupId>mysql</groupId>
-                <artifactId>mysql-connector-java</artifactId>
-                <version>${version.lib.mysql-connector-java}</version>
+                <groupId>com.mysql</groupId>
+                <artifactId>mysql-connector-j</artifactId>
+                <version>${version.lib.mysql-connector-j}</version>
             </dependency>
             <dependency>
                 <groupId>org.postgresql</groupId>
diff --git a/examples/dbclient/jdbc/pom.xml b/examples/dbclient/jdbc/pom.xml
index f9b8f33998..aeefe4db30 100644
--- a/examples/dbclient/jdbc/pom.xml
+++ b/examples/dbclient/jdbc/pom.xml
@@ -68,8 +68,8 @@
         </dependency>
 <!--
         <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
         </dependency>
 -->
 <!--
diff --git a/examples/dbclient/pokemons/pom.xml b/examples/dbclient/pokemons/pom.xml
index 6ae1b94407..f067b9607a 100644
--- a/examples/dbclient/pokemons/pom.xml
+++ b/examples/dbclient/pokemons/pom.xml
@@ -78,12 +78,6 @@
             <groupId>io.helidon.integrations.db</groupId>
             <artifactId>h2</artifactId>
         </dependency>
-<!--
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-        </dependency>
--->
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-jdk14</artifactId>
diff --git a/examples/integrations/cdi/datasource-hikaricp-mysql/pom.xml b/examples/integrations/cdi/datasource-hikaricp-mysql/pom.xml
index 9d5fdd66c6..61df50f3b3 100644
--- a/examples/integrations/cdi/datasource-hikaricp-mysql/pom.xml
+++ b/examples/integrations/cdi/datasource-hikaricp-mysql/pom.xml
@@ -51,8 +51,8 @@
 
         <!-- Runtime-scoped dependencies. -->
         <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
             <scope>runtime</scope>
             <optional>true</optional>
         </dependency>
diff --git a/integrations/db/mysql/pom.xml b/integrations/db/mysql/pom.xml
index 3515436262..7f4206ee60 100644
--- a/integrations/db/mysql/pom.xml
+++ b/integrations/db/mysql/pom.xml
@@ -36,8 +36,8 @@
 
     <dependencies>
         <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
             <scope>provided</scope>
         </dependency>
     </dependencies>
diff --git a/metrics/providers/micrometer/src/main/java/io/helidon/metrics/providers/micrometer/MicrometerPrometheusFormatter.java b/metrics/providers/micrometer/src/main/java/io/helidon/metrics/providers/micrometer/MicrometerPrometheusFormatter.java
index ebad78514a..c8aa27050f 100644
--- a/metrics/providers/micrometer/src/main/java/io/helidon/metrics/providers/micrometer/MicrometerPrometheusFormatter.java
+++ b/metrics/providers/micrometer/src/main/java/io/helidon/metrics/providers/micrometer/MicrometerPrometheusFormatter.java
@@ -131,10 +131,10 @@ public class MicrometerPrometheusFormatter implements MeterRegistryFormatter {
                 return Optional.empty();
             }
 
-            String prometheusOutput = filter(prometheusMeterRegistry.get()
-                                                     .scrape(MicrometerPrometheusFormatter.MEDIA_TYPE_TO_FORMAT.get(
-                                                                     resultMediaType),
-                                                             meterNamesOfInterest));
+            String prometheusOutput = prometheusMeterRegistry.get()
+                    .scrape(MicrometerPrometheusFormatter.MEDIA_TYPE_TO_FORMAT.get(
+                                    resultMediaType),
+                            meterNamesOfInterest);
 
             return prometheusOutput.isBlank() ? Optional.empty() : Optional.of(prometheusOutput);
         }
@@ -218,16 +218,6 @@ public class MicrometerPrometheusFormatter implements MeterRegistryFormatter {
         return result;
     }
 
-    /**
-     * Filter the Prometheus-format report.
-     *
-     * @param output Prometheus-format report
-     * @return output filtered
-     */
-    private static String filter(String output) {
-        return output.replaceFirst("# EOF\r?\n?", "");
-    }
-
     private static Optional<PrometheusMeterRegistry> prometheusMeterRegistry(MeterRegistry meterRegistry) {
         io.micrometer.core.instrument.MeterRegistry mMeterRegistry =
                 meterRegistry.unwrap(io.micrometer.core.instrument.MeterRegistry.class);


Test patch:
diff --git a/metrics/providers/micrometer/src/test/java/io/helidon/metrics/providers/micrometer/TestPrometheusFormatting.java b/metrics/providers/micrometer/src/test/java/io/helidon/metrics/providers/micrometer/TestPrometheusFormatting.java
index ac00f6e0c1..10a98c3103 100644
--- a/metrics/providers/micrometer/src/test/java/io/helidon/metrics/providers/micrometer/TestPrometheusFormatting.java
+++ b/metrics/providers/micrometer/src/test/java/io/helidon/metrics/providers/micrometer/TestPrometheusFormatting.java
@@ -19,6 +19,7 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
+import io.helidon.common.media.type.MediaTypes;
 import io.helidon.common.testing.junit5.OptionalMatcher;
 import io.helidon.metrics.api.Counter;
 import io.helidon.metrics.api.MeterRegistry;
@@ -36,6 +37,7 @@ import org.junit.jupiter.api.Test;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.allOf;
 import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.endsWith;
 import static org.hamcrest.Matchers.instanceOf;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.not;
@@ -43,6 +45,13 @@ import static org.hamcrest.Matchers.not;
 class TestPrometheusFormatting {
 
     private static final String SCOPE_TAG_NAME = "this-scope";
+
+    /*
+    Only OpenMetrics format, not the Prometheus exposition format, has the trailing EOF which (for example) the Prometheus
+    server expects to see when it probes targets. That's why, below, when we format the output, we specify OpenMetrics as the
+    media type.
+     */
+    private static final String OPENMETRICS_EOF = "# EOF\n";
     private static MeterRegistry meterRegistry;
 
     private static MetricsConfig metricsConfig;
@@ -87,13 +96,15 @@ class TestPrometheusFormatting {
         e.record(2, TimeUnit.SECONDS);
 
         MicrometerPrometheusFormatter formatter = MicrometerPrometheusFormatter.builder(meterRegistry)
+                .resultMediaType(MediaTypes.APPLICATION_OPENMETRICS_TEXT)
                 .scopeTagName(SCOPE_TAG_NAME)
                 .build();
         Optional<Object> outputOpt = formatter.format();
 
         assertThat("Formatted output",
                    checkAndCast(outputOpt),
-                   allOf(containsString(scopeExpr("c1_total",
+                   allOf(
+                           containsString(scopeExpr("c1_total",
                                                   "this_scope",
                                                   "app",
                                                   "1.0")),
@@ -108,7 +119,9 @@ class TestPrometheusFormatting {
                          containsString(scopeExpr("t1_1_seconds_count",
                                                   "this_scope",
                                                   "app",
-                                                  "1.0"))));
+                                                  "1.0")),
+                         endsWith(OPENMETRICS_EOF)));
+
     }
 
     @Test
@@ -122,6 +135,7 @@ class TestPrometheusFormatting {
         d.record(7, TimeUnit.SECONDS);
 
         MicrometerPrometheusFormatter formatter = MicrometerPrometheusFormatter.builder(meterRegistry)
+                .resultMediaType(MediaTypes.APPLICATION_OPENMETRICS_TEXT)
                 .scopeTagName(SCOPE_TAG_NAME)
                 .meterNameSelection(Set.of("c2"))
                 .build();
@@ -139,7 +153,8 @@ class TestPrometheusFormatting {
                                                       "1.0"))),
                          not(containsString(scopeExpr("t2_seconds_sum",
                                                       "this_scope",
-                                                      "app", "7.0")))));
+                                                      "app", "7.0"))),
+                         endsWith(OPENMETRICS_EOF)));
 
     }
 
@@ -159,6 +174,7 @@ class TestPrometheusFormatting {
         e.record(2, TimeUnit.SECONDS);
 
         MicrometerPrometheusFormatter formatter = MicrometerPrometheusFormatter.builder(meterRegistry)
+                .resultMediaType(MediaTypes.APPLICATION_OPENMETRICS_TEXT)
                 .scopeTagName(SCOPE_TAG_NAME)
                 .scopeSelection(Set.of("app"))
                 .build();
@@ -182,11 +198,12 @@ class TestPrometheusFormatting {
                          containsString(scopeExpr("t3_1_seconds_count",
                                                   "this_scope",
                                                   "app",
-                                                  "1.0"))));
+                                                  "1.0")),
+                         endsWith(OPENMETRICS_EOF)));
     }
 
     private static String scopeExpr(String meterName, String key, String value, String suffix) {
-        return meterName + "{" + key + "=\"" + value + "\",} " + suffix;
+        return meterName + "{" + key + "=\"" + value + "\"} " + suffix;
     }
 
     private static String checkAndCast(Optional<Object> outputOpt) {
diff --git a/tests/integration/dbclient/app/pom.xml b/tests/integration/dbclient/app/pom.xml
index 4e5a08a8e2..93926f3add 100644
--- a/tests/integration/dbclient/app/pom.xml
+++ b/tests/integration/dbclient/app/pom.xml
@@ -236,8 +236,8 @@
                     <version>${project.version}</version>
                 </dependency>
                 <dependency>
-                    <groupId>mysql</groupId>
-                    <artifactId>mysql-connector-java</artifactId>
+                    <groupId>com.mysql</groupId>
+                    <artifactId>mysql-connector-j</artifactId>
                 </dependency>
             </dependencies>
         </profile>
diff --git a/tests/integration/jpa/appl/pom.xml b/tests/integration/jpa/appl/pom.xml
index 2baa0679a1..6dff1a3e7b 100644
--- a/tests/integration/jpa/appl/pom.xml
+++ b/tests/integration/jpa/appl/pom.xml
@@ -380,8 +380,8 @@
                     <version>${project.version}</version>
                 </dependency>
                 <dependency>
-                    <groupId>mysql</groupId>
-                    <artifactId>mysql-connector-java</artifactId>
+                    <groupId>com.mysql</groupId>
+                    <artifactId>mysql-connector-j</artifactId>
                     <scope>runtime</scope>
                 </dependency>
             </dependencies>
diff --git a/tests/integration/vault/pom.xml b/tests/integration/vault/pom.xml
index dd7c93adb6..ad7cdf6539 100644
--- a/tests/integration/vault/pom.xml
+++ b/tests/integration/vault/pom.xml
@@ -104,8 +104,8 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>