Skip to content

Commit ae9b591

Browse files
committed
Applied rewrite java 17 migration
$ mvn clean -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:RELEASE -Drewrite.activeRecipes=org.openrewrite.java.migrate.UpgradeToJava17 -Drewrite.exportDatatables=true Signed-off-by: Marvin Froeder <marvin@datasqrl.com>
1 parent abfbc4c commit ae9b591

File tree

19 files changed

+60
-75
lines changed

19 files changed

+60
-75
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: actions/setup-java@v3
3333
with:
3434
distribution: 'temurin'
35-
java-version: '11'
35+
java-version: '17'
3636

3737
- name: Import GPG Key
3838
if: github.event_name != 'pull_request'

.github/workflows/uber-jar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
uses: actions/setup-java@v3
3737
with:
3838
distribution: 'temurin'
39-
java-version: '11'
39+
java-version: '17'
4040

4141
- name: Generate settings.xml
4242
run: |

connectors/postgresql-connector/src/main/java/com/datasqrl/connector/postgresql/jdbc/SqrlBaseJdbcRowConverter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public JdbcDeserializationConverter createInternalConverter(LogicalType type) {
6666

6767
if (root == LogicalTypeRoot.TIMESTAMP_WITH_LOCAL_TIME_ZONE) {
6868
return val ->
69-
val instanceof LocalDateTime
70-
? TimestampData.fromLocalDateTime((LocalDateTime) val)
69+
val instanceof LocalDateTime ldt
70+
? TimestampData.fromLocalDateTime(ldt)
7171
: TimestampData.fromTimestamp((Timestamp) val);
7272
} else if (root == LogicalTypeRoot.ARRAY) {
7373
ArrayType arrayType = (ArrayType) type;
@@ -101,10 +101,10 @@ private void createSqlArrayObject(
101101
// Scalar arrays of any dimension are one array call
102102
if (isScalarArray(type)) {
103103
Object[] boxed;
104-
if (data instanceof GenericArrayData) {
105-
boxed = ((GenericArrayData) data).toObjectArray();
106-
} else if (data instanceof BinaryArrayData) {
107-
boxed = ((BinaryArrayData) data).toObjectArray(getBaseFlinkArrayType(type));
104+
if (data instanceof GenericArrayData arrayData) {
105+
boxed = arrayData.toObjectArray();
106+
} else if (data instanceof BinaryArrayData arrayData) {
107+
boxed = arrayData.toObjectArray(getBaseFlinkArrayType(type));
108108
} else {
109109
throw new RuntimeException("Unsupported ArrayData type: " + data.getClass());
110110
}

connectors/postgresql-connector/src/main/java/com/datasqrl/connector/postgresql/jdbc/SqrlJdbcDynamicTableFactory.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -229,38 +229,36 @@ private void validateConfigOptions(ReadableConfig config, ClassLoader classLoade
229229
long upperBound = config.get(SCAN_PARTITION_UPPER_BOUND);
230230
if (lowerBound > upperBound) {
231231
throw new IllegalArgumentException(
232-
String.format(
233-
"'%s'='%s' must not be larger than '%s'='%s'.",
234-
SCAN_PARTITION_LOWER_BOUND.key(),
235-
lowerBound,
236-
SCAN_PARTITION_UPPER_BOUND.key(),
237-
upperBound));
232+
"'%s'='%s' must not be larger than '%s'='%s'."
233+
.formatted(
234+
SCAN_PARTITION_LOWER_BOUND.key(),
235+
lowerBound,
236+
SCAN_PARTITION_UPPER_BOUND.key(),
237+
upperBound));
238238
}
239239
}
240240

241241
checkAllOrNone(config, new ConfigOption[] {LOOKUP_CACHE_MAX_ROWS, LOOKUP_CACHE_TTL});
242242

243243
if (config.get(LOOKUP_MAX_RETRIES) < 0) {
244244
throw new IllegalArgumentException(
245-
String.format(
246-
"The value of '%s' option shouldn't be negative, but is %s.",
247-
LOOKUP_MAX_RETRIES.key(), config.get(LOOKUP_MAX_RETRIES)));
245+
"The value of '%s' option shouldn't be negative, but is %s."
246+
.formatted(LOOKUP_MAX_RETRIES.key(), config.get(LOOKUP_MAX_RETRIES)));
248247
}
249248

250249
if (config.get(SINK_MAX_RETRIES) < 0) {
251250
throw new IllegalArgumentException(
252-
String.format(
253-
"The value of '%s' option shouldn't be negative, but is %s.",
254-
SINK_MAX_RETRIES.key(), config.get(SINK_MAX_RETRIES)));
251+
"The value of '%s' option shouldn't be negative, but is %s."
252+
.formatted(SINK_MAX_RETRIES.key(), config.get(SINK_MAX_RETRIES)));
255253
}
256254

257255
if (config.get(MAX_RETRY_TIMEOUT).getSeconds() <= 0) {
258256
throw new IllegalArgumentException(
259-
String.format(
260-
"The value of '%s' option must be in second granularity and shouldn't be smaller than 1 second, but is %s.",
261-
MAX_RETRY_TIMEOUT.key(),
262-
config.get(
263-
ConfigOptions.key(MAX_RETRY_TIMEOUT.key()).stringType().noDefaultValue())));
257+
"The value of '%s' option must be in second granularity and shouldn't be smaller than 1 second, but is %s."
258+
.formatted(
259+
MAX_RETRY_TIMEOUT.key(),
260+
config.get(
261+
ConfigOptions.key(MAX_RETRY_TIMEOUT.key()).stringType().noDefaultValue())));
264262
}
265263
}
266264

connectors/postgresql-connector/src/main/java/com/datasqrl/connector/postgresql/jdbc/SqrlPostgresDialect.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.datasqrl.connector.postgresql.jdbc;
1717

18+
import java.io.Serial;
1819
import java.util.Arrays;
1920
import java.util.EnumSet;
2021
import java.util.List;
@@ -36,7 +37,7 @@
3637
*/
3738
public class SqrlPostgresDialect extends AbstractDialect {
3839

39-
private static final long serialVersionUID = 1L;
40+
@Serial private static final long serialVersionUID = 1L;
4041

4142
// Define MAX/MIN precision of TIMESTAMP type according to PostgreSQL docs:
4243
// https://www.postgresql.org/docs/12/datatype-datetime.html
@@ -93,8 +94,8 @@ public void validate(RowType rowType) throws ValidationException {
9394

9495
if (!unsupportedTypes.isEmpty()) {
9596
throw new ValidationException(
96-
String.format(
97-
"The %s dialect doesn't support type: %s.", this.dialectName(), unsupportedTypes));
97+
"The %s dialect doesn't support type: %s."
98+
.formatted(this.dialectName(), unsupportedTypes));
9899
}
99100

100101
super.validate(rowType);

connectors/postgresql-connector/src/main/java/com/datasqrl/connector/postgresql/jdbc/SqrlPostgresRowConverter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.datasqrl.connector.postgresql.jdbc;
1717

1818
import com.datasqrl.connector.postgresql.type.JdbcTypeSerializer;
19+
import java.io.Serial;
1920
import java.lang.reflect.Type;
2021
import java.util.Map;
2122
import java.util.ServiceLoader;
@@ -35,7 +36,7 @@
3536
*/
3637
public class SqrlPostgresRowConverter extends SqrlBaseJdbcRowConverter {
3738

38-
private static final long serialVersionUID = 1L;
39+
@Serial private static final long serialVersionUID = 1L;
3940

4041
public static final Map<
4142
Type, JdbcTypeSerializer<JdbcDeserializationConverter, JdbcSerializationConverter>>
@@ -104,8 +105,7 @@ public JdbcDeserializationConverter createArrayConverter(ArrayType arrayType) {
104105
// sqrl: check if scalar array
105106

106107
Object[] in;
107-
if (val instanceof PgArray) {
108-
PgArray pgArray = (PgArray) val;
108+
if (val instanceof PgArray pgArray) {
109109
in = (Object[]) pgArray.getArray();
110110
} else {
111111
in = (Object[]) val;

connectors/postgresql-connector/src/main/java/com/datasqrl/connector/postgresql/type/FlinkArrayTypeUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
public class FlinkArrayTypeUtil {
2222

2323
public static LogicalType getBaseFlinkArrayType(LogicalType type) {
24-
if (type instanceof ArrayType) {
25-
return getBaseFlinkArrayType(((ArrayType) type).getElementType());
24+
if (type instanceof ArrayType arrayType) {
25+
return getBaseFlinkArrayType(arrayType.getElementType());
2626
}
2727
return type;
2828
}
2929

3030
public static boolean isScalarArray(LogicalType type) {
31-
if (type instanceof ArrayType) {
32-
LogicalType elementType = ((ArrayType) type).getElementType();
31+
if (type instanceof ArrayType arrayType) {
32+
LogicalType elementType = arrayType.getElementType();
3333
return isScalar(elementType) || isScalarArray(elementType);
3434
}
3535
return false;

flink-sql-runner/pom.xml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -476,16 +476,7 @@
476476
<flink.version>1.19.2</flink.version>
477477
<jdbc.version>3.2.0-1.19</jdbc.version>
478478
<kafka.version>3.2.0-1.19</kafka.version>
479-
<flink-base-image>1.19.2-scala_2.12-java11</flink-base-image>
480-
</properties>
481-
</profile>
482-
<profile>
483-
<id>flink-1.18</id>
484-
<properties>
485-
<flink.version>1.18.1</flink.version>
486-
<jdbc.version>3.2.0-1.18</jdbc.version>
487-
<kafka.version>3.2.0-1.18</kafka.version>
488-
<flink-base-image>1.18.1-scala_2.12-java11</flink-base-image>
479+
<flink-base-image>1.19.2-scala_2.12-java17</flink-base-image>
489480
</properties>
490481
</profile>
491482

flink-sql-runner/src/main/java/com/datasqrl/EnvironmentVariablesUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static String replaceWithEnv(String command, Map<String, String> envVaria
4343
String key = matcher.group(1);
4444
String envValue = envVariables.get(key);
4545
if (envValue == null) {
46-
throw new IllegalStateException(String.format("Missing environment variable: %s", key));
46+
throw new IllegalStateException("Missing environment variable: %s".formatted(key));
4747
}
4848
matcher.appendReplacement(result, Matcher.quoteReplacement(envValue));
4949
}

flink-sql-runner/src/main/java/com/datasqrl/FlinkMain.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,8 @@ public int run() throws Exception {
111111
EnvironmentVariablesUtils.validateEnvironmentVariables(script);
112112
if (!missingEnvironmentVariables.isEmpty()) {
113113
throw new IllegalStateException(
114-
String.format(
115-
"Could not find the following environment variables: %s",
116-
missingEnvironmentVariables));
114+
"Could not find the following environment variables: %s"
115+
.formatted(missingEnvironmentVariables));
117116
}
118117

119118
tableResult = sqlExecutor.executeScript(script);
@@ -125,9 +124,8 @@ public int run() throws Exception {
125124
EnvironmentVariablesUtils.validateEnvironmentVariables(planJson);
126125
if (!missingEnvironmentVariables.isEmpty()) {
127126
throw new IllegalStateException(
128-
String.format(
129-
"Could not find the following environment variables: %s",
130-
missingEnvironmentVariables));
127+
"Could not find the following environment variables: %s"
128+
.formatted(missingEnvironmentVariables));
131129
}
132130

133131
planJson = replaceScriptWithEnv(planJson);

0 commit comments

Comments
 (0)