-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(java): Full java 17 only support (#2107)
* chore(java): Full java 17 only * chore(java): Full java 17 only * chore(java): Full java 17 only * chore(java): Let gradle plugin compat set the target and source versions * chore(java): Attempt to fix the serialization behavior on linux when using Instant clocks and sql conversions of the JSON string from that conversion * fix(sql): Attempting to fix the precision error in a slightly different manner * fix(sql): Attempting to fix the precision error in a slightly different manner * fix(sql): Attempting to fix the precision error by force setting mapping of instants * fix(sql): Use base date time serializer with some mods * fix(sql): Use less precision on comparison to an instant now * fix(sql): Test ONLY with serializer vs serial and deserializer * fix(sql): Now with tests passing remove the extraneous code * fix(sql): Document the changes * fix(sql): Add test verifying precision and adjust precision to 6 to match mysql * fix(sql): Adjust comment and change to MICROS for tests
- Loading branch information
1 parent
072ccd6
commit 784a3d1
Showing
14 changed files
with
107 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
FROM ubuntu:bionic | ||
FROM ubuntu:jammy | ||
LABEL maintainer="[email protected]" | ||
RUN echo "mysql-server mysql-server/root_password password sa" | debconf-set-selections | ||
RUN echo "mysql-server mysql-server/root_password_again password sa" | debconf-set-selections | ||
RUN apt-get update && apt-get install -y \ | ||
openjdk-11-jdk \ | ||
openjdk-17-jdk \ | ||
mysql-server \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
ENV GRADLE_USER_HOME /workspace/.gradle | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FROM alpine:3.11 | ||
FROM alpine:3.20 | ||
LABEL maintainer="[email protected]" | ||
RUN apk --no-cache add --update bash openjdk11-jre | ||
RUN apk --no-cache add --update bash openjdk17-jre | ||
RUN addgroup -S -g 10111 spinnaker | ||
RUN adduser -S -G spinnaker -u 10111 spinnaker | ||
COPY keel-web/build/install/keel /opt/keel | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FROM ubuntu:bionic | ||
FROM ubuntu:jammy | ||
LABEL maintainer="[email protected]" | ||
RUN apt-get update && apt-get -y install openjdk-11-jre-headless wget | ||
RUN apt-get update && apt-get -y install openjdk-17-jre-headless wget | ||
RUN adduser --system --uid 10111 --group spinnaker | ||
COPY keel-web/build/install/keel /opt/keel | ||
RUN mkdir -p /opt/keel/plugins && chown -R spinnaker:nogroup /opt/keel/plugins | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
keel-core/src/main/java/com/netflix/spinnaker/keel/serialization/PrecisionSqlSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.netflix.spinnaker.keel.serialization; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.fasterxml.jackson.datatype.jsr310.ser.InstantSerializerBase; | ||
import java.time.Instant; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.DateTimeFormatterBuilder; | ||
|
||
/** | ||
* This class overloads the default Serialization instance in the JavaTimeModule to a precision | ||
* level that the database can process via str_to_date string conversion It's needed because we do | ||
* JSON serialization to a column and then the column gets used to generate another field via string | ||
* conversion. Specifically * triggered_at * dismissed_at are "generated" columns. NOTE this should | ||
* ONLY impact running on Linux as the system clock on Linux systems returns a higher precision in | ||
* Java 17+. It's also impactful as ISO_INSTANT has NO precision limitation giving inconsistent | ||
* string output as a result | ||
* | ||
* <p>See | ||
* | ||
* <ul> | ||
* <li>https://stackoverflow.com/questions/74781495/changes-in-instant-now-between-java-11-and-java-17-in-aws-ubuntu-standard-6-0 | ||
* <li>https://stackoverflow.com/a/38042457 for more information. | ||
* </ul> | ||
* | ||
* <p>NOTE we're going to 6 digits to match <a | ||
* href="https://www.w3schools.com/sql/func_mysql_str_to_date.asp">Mysql str_to_date function | ||
* limits</a> on microseconds parsing. This is used in the SQL definition: <code> | ||
* add column triggered_at datetime(3) generated always as (str_to_date(json->>'$.triggeredAt', '%Y-%m-%dT%T.%fZ')) | ||
* </code> column in the 20210616-create-dismissible-notifications.yml liquibase change set. | ||
*/ | ||
public class PrecisionSqlSerializer extends InstantSerializerBase<Instant> { | ||
public PrecisionSqlSerializer() { | ||
super( | ||
Instant.class, | ||
Instant::toEpochMilli, | ||
Instant::getEpochSecond, | ||
Instant::getNano, | ||
new DateTimeFormatterBuilder().appendInstant(6).toFormatter()); | ||
} | ||
|
||
@Override | ||
protected InstantSerializerBase<?> withFormat( | ||
Boolean aBoolean, DateTimeFormatter dateTimeFormatter, JsonFormat.Shape shape) { | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...rc/test/kotlin/com/netflix/spinnaker/keel/serialization/ObjectMapperSerializationTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.netflix.spinnaker.keel.serialization | ||
|
||
import dev.minutest.junit.JUnit5Minutests | ||
import dev.minutest.rootContext | ||
import org.assertj.core.api.Assertions.assertThat | ||
import java.time.Instant | ||
import java.time.LocalDateTime | ||
import java.time.OffsetDateTime | ||
import java.time.ZoneOffset | ||
import java.time.format.DateTimeFormatter | ||
import java.time.format.DateTimeFormatterBuilder | ||
|
||
class ObjectMapperSerializationTests : JUnit5Minutests { | ||
|
||
class ObjectMapperSerializationTestsObject { | ||
var date = Instant.from(DateTimeFormatter.ISO_INSTANT.parse("2024-03-10T12:28:19.228816801Z")) | ||
} | ||
|
||
fun tests() = rootContext { | ||
test("Verify instant precision is no more than 6 characters") { | ||
val mapper = configuredObjectMapper() | ||
val sampleObject = ObjectMapperSerializationTestsObject() | ||
val readBack = mapper.readValue( | ||
mapper.writeValueAsString(sampleObject), | ||
ObjectMapperSerializationTestsObject::class.java | ||
) | ||
// 6 precision is the max allowed via str_to_date in SQL. See | ||
// https://dev.mysql.com/doc/refman/8.4/en/date-and-time-type-syntax.html#:~:text=MySQL%20permits%20fractional%20seconds%20for,microseconds%20(6%20digits)%20precision. | ||
// SO we want to make sure waht we store matches this | ||
val foramt = DateTimeFormatterBuilder().parseCaseInsensitive().appendInstant(6).parseStrict().toFormatter() | ||
assertThat(readBack.date).isEqualTo(foramt.format(sampleObject.date)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ryuk.container.image = public.ecr.aws/s4w6t4b6/testcontainers/ryuk:0.3.4 | ||
ryuk.container.image = testcontainers/ryuk:0.11.0 |