Skip to content

Commit 8538769

Browse files
authored
Restore Feast Java SDK and Ingestion compatibility with Java 8 runtimes (feast-dev#722)
* Make storage modules target Java 8, since Ingestion must With the addition of the Storage APIs and connector implementations, we did not specify that their build should target Java 8 bytecode. Because Ingestion depends on them, we regressed on keeping Ingestion compatible with Java 8 runtimes according to feast-dev#518. This could be confirmed prior to this change with, for example: $ mvn -pl ingestion clean compile $ javap -v storage/connectors/redis/target/classes/feast/storage/connectors/redis/writer/RedisCustomIO.class | grep major major version: 55 I take this as proof that a blacklist approach with 11 as the default in our root POM is error prone, so this change flips it so that 8 is default and our leaf applications that are able use 11 opt into it in whitelist fashion. * Target Java 8 compatibility for Java SDK
1 parent ec7d413 commit 8538769

10 files changed

Lines changed: 63 additions & 32 deletions

File tree

core/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232

3333
<build>
3434
<plugins>
35+
<plugin>
36+
<groupId>org.apache.maven.plugins</groupId>
37+
<artifactId>maven-compiler-plugin</artifactId>
38+
<configuration>
39+
<release>11</release>
40+
</configuration>
41+
</plugin>
42+
3543
<plugin>
3644
<groupId>org.jacoco</groupId>
3745
<artifactId>jacoco-maven-plugin</artifactId>

datatypes/java/pom.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,6 @@
3737

3838
<build>
3939
<plugins>
40-
<plugin>
41-
<groupId>org.apache.maven.plugins</groupId>
42-
<artifactId>maven-compiler-plugin</artifactId>
43-
<configuration>
44-
<!-- To ensure Ingestion remains compatible for Java 8-only Beam runners -->
45-
<release>8</release>
46-
</configuration>
47-
</plugin>
48-
4940
<plugin>
5041
<groupId>org.apache.maven.plugins</groupId>
5142
<artifactId>maven-dependency-plugin</artifactId>

ingestion/pom.xml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@
3131

3232
<build>
3333
<plugins>
34-
<plugin>
35-
<groupId>org.apache.maven.plugins</groupId>
36-
<artifactId>maven-compiler-plugin</artifactId>
37-
<configuration>
38-
<!-- To ensure Ingestion remains compatible for Java 8-only Beam runners -->
39-
<release>8</release>
40-
</configuration>
41-
</plugin>
42-
4334
<plugin>
4435
<groupId>org.apache.maven.plugins</groupId>
4536
<artifactId>maven-shade-plugin</artifactId>
@@ -84,6 +75,31 @@
8475
</executions>
8576
</plugin>
8677

78+
<plugin>
79+
<groupId>org.apache.maven.plugins</groupId>
80+
<artifactId>maven-enforcer-plugin</artifactId>
81+
<executions>
82+
<!--
83+
We want to keep Ingestion compatible with Java 8 runtime for Beam runners, #518.
84+
Unfortunately this doesn't seem to work on Reactor modules, though:
85+
https://github.com/mojohaus/mojo-parent/issues/85
86+
-->
87+
<execution>
88+
<id>enforce-bytecode-version</id>
89+
<goals>
90+
<goal>enforce</goal>
91+
</goals>
92+
<configuration>
93+
<rules>
94+
<enforceBytecodeVersion>
95+
<maxJdkVersion>1.8</maxJdkVersion>
96+
</enforceBytecodeVersion>
97+
</rules>
98+
</configuration>
99+
</execution>
100+
</executions>
101+
</plugin>
102+
87103
<plugin>
88104
<groupId>org.jacoco</groupId>
89105
<artifactId>jacoco-maven-plugin</artifactId>

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,8 @@
417417
<groupId>org.apache.maven.plugins</groupId>
418418
<artifactId>maven-compiler-plugin</artifactId>
419419
<configuration>
420-
<release>11</release>
420+
<!-- Our leaf applications target 11, except Ingestion and its deps remain on 8 for Beam -->
421+
<release>8</release>
421422
</configuration>
422423
</plugin>
423424
<plugin>

sdk/java/src/test/java/com/gojek/feast/RequestUtilTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.junit.jupiter.api.Assertions.assertEquals;
2020
import static org.junit.jupiter.api.Assertions.assertThrows;
2121

22+
import com.google.common.collect.ImmutableList;
2223
import com.google.protobuf.TextFormat;
2324
import feast.proto.serving.ServingAPIProto.FeatureReference;
2425
import java.util.Arrays;
@@ -82,7 +83,7 @@ void renderFeatureRef_ShouldReturnFeatureRefString(
8283
}
8384

8485
private static Stream<Arguments> provideInvalidFeatureRefs() {
85-
return Stream.of(Arguments.of(List.of("project/feature", "")));
86+
return Stream.of(Arguments.of(ImmutableList.of("project/feature", "")));
8687
}
8788

8889
@ParameterizedTest

serving/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040

4141
<build>
4242
<plugins>
43+
<plugin>
44+
<groupId>org.apache.maven.plugins</groupId>
45+
<artifactId>maven-compiler-plugin</artifactId>
46+
<configuration>
47+
<release>11</release>
48+
</configuration>
49+
</plugin>
50+
4351
<plugin>
4452
<groupId>org.jacoco</groupId>
4553
<artifactId>jacoco-maven-plugin</artifactId>

storage/connectors/redis/src/main/java/feast/storage/connectors/redis/writer/RedisCustomIO.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ public class RedisCustomIO {
5454
private static final int DEFAULT_BATCH_SIZE = 1000;
5555
private static final int DEFAULT_TIMEOUT = 2000;
5656

57-
private static TupleTag<FeatureRow> successfulInsertsTag = new TupleTag<>("successfulInserts") {};
58-
private static TupleTag<FailedElement> failedInsertsTupleTag = new TupleTag<>("failedInserts") {};
57+
private static TupleTag<FeatureRow> successfulInsertsTag =
58+
new TupleTag<FeatureRow>("successfulInserts") {};
59+
private static TupleTag<FailedElement> failedInsertsTupleTag =
60+
new TupleTag<FailedElement>("failedInserts") {};
5961

6062
private static final Logger log = LoggerFactory.getLogger(RedisCustomIO.class);
6163

storage/connectors/redis/src/test/java/feast/storage/connectors/redis/retriever/RedisOnlineRetrieverTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void shouldReturnResponseWithValuesIfKeysPresent() {
133133
when(syncCommands.mget(redisKeyList)).thenReturn(featureRowBytes);
134134

135135
List<List<FeatureRow>> expected =
136-
List.of(
136+
ImmutableList.of(
137137
Lists.newArrayList(
138138
FeatureRow.newBuilder()
139139
.setEventTimestamp(Timestamp.newBuilder().setSeconds(100))
@@ -153,7 +153,7 @@ public void shouldReturnResponseWithValuesIfKeysPresent() {
153153
.build()));
154154

155155
List<List<FeatureRow>> actual =
156-
redisOnlineRetriever.getOnlineFeatures(entityRows, List.of(featureSetRequest));
156+
redisOnlineRetriever.getOnlineFeatures(entityRows, ImmutableList.of(featureSetRequest));
157157
assertThat(actual, equalTo(expected));
158158
}
159159

@@ -201,7 +201,7 @@ public void shouldReturnResponseWithUnsetValuesIfKeysNotPresent() {
201201
when(syncCommands.mget(redisKeyList)).thenReturn(featureRowBytes);
202202

203203
List<List<FeatureRow>> expected =
204-
List.of(
204+
ImmutableList.of(
205205
Lists.newArrayList(
206206
FeatureRow.newBuilder()
207207
.setEventTimestamp(Timestamp.newBuilder().setSeconds(100))
@@ -220,7 +220,7 @@ public void shouldReturnResponseWithUnsetValuesIfKeysNotPresent() {
220220
.build()));
221221

222222
List<List<FeatureRow>> actual =
223-
redisOnlineRetriever.getOnlineFeatures(entityRows, List.of(featureSetRequest));
223+
redisOnlineRetriever.getOnlineFeatures(entityRows, ImmutableList.of(featureSetRequest));
224224
assertThat(actual, equalTo(expected));
225225
}
226226

storage/connectors/rediscluster/src/main/java/feast/storage/connectors/rediscluster/writer/RedisClusterCustomIO.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ public class RedisClusterCustomIO {
5454
private static final int DEFAULT_BATCH_SIZE = 1000;
5555
private static final int DEFAULT_TIMEOUT = 2000;
5656

57-
private static TupleTag<FeatureRow> successfulInsertsTag = new TupleTag<>("successfulInserts") {};
58-
private static TupleTag<FailedElement> failedInsertsTupleTag = new TupleTag<>("failedInserts") {};
57+
private static TupleTag<FeatureRow> successfulInsertsTag =
58+
new TupleTag<FeatureRow>("successfulInserts") {};
59+
private static TupleTag<FailedElement> failedInsertsTupleTag =
60+
new TupleTag<FailedElement>("failedInserts") {};
5961

6062
private static final Logger log = LoggerFactory.getLogger(RedisClusterCustomIO.class);
6163

storage/connectors/rediscluster/src/test/java/feast/storage/connectors/rediscluster/retriever/RedisClusterOnlineRetrieverTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void shouldReturnResponseWithValuesIfKeysPresent() {
133133
when(syncCommands.mget(redisKeyList)).thenReturn(featureRowBytes);
134134

135135
List<List<FeatureRow>> expected =
136-
List.of(
136+
ImmutableList.of(
137137
Lists.newArrayList(
138138
FeatureRow.newBuilder()
139139
.setEventTimestamp(Timestamp.newBuilder().setSeconds(100))
@@ -153,7 +153,8 @@ public void shouldReturnResponseWithValuesIfKeysPresent() {
153153
.build()));
154154

155155
List<List<FeatureRow>> actual =
156-
redisClusterOnlineRetriever.getOnlineFeatures(entityRows, List.of(featureSetRequest));
156+
redisClusterOnlineRetriever.getOnlineFeatures(
157+
entityRows, ImmutableList.of(featureSetRequest));
157158
assertThat(actual, equalTo(expected));
158159
}
159160

@@ -201,7 +202,7 @@ public void shouldReturnResponseWithUnsetValuesIfKeysNotPresent() {
201202
when(syncCommands.mget(redisKeyList)).thenReturn(featureRowBytes);
202203

203204
List<List<FeatureRow>> expected =
204-
List.of(
205+
ImmutableList.of(
205206
Lists.newArrayList(
206207
FeatureRow.newBuilder()
207208
.setEventTimestamp(Timestamp.newBuilder().setSeconds(100))
@@ -220,7 +221,8 @@ public void shouldReturnResponseWithUnsetValuesIfKeysNotPresent() {
220221
.build()));
221222

222223
List<List<FeatureRow>> actual =
223-
redisClusterOnlineRetriever.getOnlineFeatures(entityRows, List.of(featureSetRequest));
224+
redisClusterOnlineRetriever.getOnlineFeatures(
225+
entityRows, ImmutableList.of(featureSetRequest));
224226
assertThat(actual, equalTo(expected));
225227
}
226228

0 commit comments

Comments
 (0)