Skip to content

Commit

Permalink
Workaround DateTimeParseException in vertx-sql-client with JDK 22
Browse files Browse the repository at this point in the history
Workaround for quarkusio#37208 till
eclipse-vertx/vertx-sql-client#1379 gets fixed
and released

Note that the substitution only happens if necessary (i.e. it won't
happen when using JDK < 22, and it won't happen once an upstream fix
becomes available.

Closes quarkusio#37208
  • Loading branch information
zakkak committed Dec 12, 2023
1 parent 0b7462d commit 5072541
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package io.quarkus.vertx.core.runtime.graal;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import java.util.function.BooleanSupplier;

import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLException;
import javax.net.ssl.TrustManagerFactory;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

Expand Down Expand Up @@ -197,6 +202,34 @@ static List<String> get() {
}
}

@TargetClass(className = "io.vertx.pgclient.impl.codec.DataTypeCodec", onlyWith = DataTypeCodecNeedsWorkaround.class)
final class Target_io_vertx_pgclient_impl_codec_DataTypeCodec {

// Workaround for https://github.com/quarkusio/quarkus/issues/37208 till
// https://github.com/eclipse-vertx/vertx-sql-client/issues/1379 gets fixed and released
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias)
@Alias
public static LocalDateTime LDT_MINUS_INFINITY = LocalDateTime.parse("4714-11-24 00:00:00 BC",
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss G", Locale.US));
}

final class DataTypeCodecNeedsWorkaround implements BooleanSupplier {

@Override
public boolean getAsBoolean() {
try {
Class.forName("io.vertx.pgclient.impl.codec.DataTypeCodec");
} catch (java.lang.ExceptionInInitializerError e) {
if (e.getCause() instanceof java.time.format.DateTimeParseException) {
return true;
}
} catch (ClassNotFoundException ignored) {
// Ignore
}
return false;
}
}

class VertxSubstitutions {

}

0 comments on commit 5072541

Please sign in to comment.