Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] upgrade to java 21 #1655

Merged
merged 10 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/check-license-header.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
# don't use setup-java cache - hash file pattern has issues
- name: Cache local Maven repository
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/helm-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Helm
uses: azure/setup-helm@v1
Expand Down Expand Up @@ -56,4 +56,4 @@ jobs:
run: |
yq e 'select(.kind == "ConfigMap" and .metadata.name == "thirdeye-worker")' rendered.yaml > worker-configmap.yaml
yq e '.data."server.yaml"' worker-configmap.yaml > worker-config.yaml
yq e '.' worker-config.yaml
yq e '.' worker-config.yaml
4 changes: 2 additions & 2 deletions .github/workflows/publish-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
steps:
- name: Pull repository
uses: actions/checkout@v4
- name: Install JDK 17
- name: Install JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Cache - restore local Maven repository
id: cache-restore
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
cache: "npm"
cache-dependency-path: './thirdeye-ui/package-lock.json'
# java is required to get the backend project version with maven
- name: Install JDK 17
- name: Install JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Generate frontend distribution
id: generate-frontend-dist
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ jobs:
steps:
- name: Pull repository
uses: actions/checkout@v4
- name: Install JDK 17
- name: Install JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Set git ci user info
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-backend-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
timeout-minutes: 20

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install java and setup artifactory
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
server-id: startree-releases
server-username: ARTIFACTORY_USERNAME_REF
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# the License.
#

FROM eclipse-temurin:17-jdk-alpine as builder
FROM eclipse-temurin:21-jdk-alpine AS builder
# build jcmd tools to make them available at runtime
RUN ${JAVA_HOME}/bin/jlink --module-path jmods --add-modules jdk.jcmd --output /jcmd
WORKDIR /build
Expand All @@ -21,7 +21,7 @@ COPY ./ ./
# if the disitrbution is provided, do nothing - else build it
RUN if [[ ! -d thirdeye-distribution/target/thirdeye-distribution-*-dist/thirdeye-distribution-* ]]; then ./mvnw package -U -DskipTests; fi

FROM eclipse-temurin:17-jre-alpine
FROM eclipse-temurin:21-jre-alpine
RUN addgroup -g 1000 thirdeye && \
adduser -u 1000 thirdeye -G thirdeye -D

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ For a complete description of ThirdEye's features, see [**ThirdEye documentation

### Requirements
- tested on Linux and Mac OS
- Java 17
- Java 21
- MySQL 8.0
- the UI requires internal npm packages. Make sure you can access them. See [thirdeye-ui prerequisites](./thirdeye-ui/README.md#configure-node-package-manager-npm-for-use-with-artifactory)

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</modules>

<properties>
<jdk.version>17</jdk.version>
<jdk.version>21</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- Dependency Versions -->
Expand Down Expand Up @@ -232,7 +232,7 @@
<!-- download weaver jar - required for surefire goals-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<version>3.8.1</version>
<executions>
<execution>
<id>resolve</id>
Expand Down
2 changes: 1 addition & 1 deletion thirdeye-benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmh.version>1.37</jmh.version>
<javac.target>17</javac.target>
<javac.target>21</javac.target>
<uberjar.name>benchmarks</uberjar.name>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private SqlNode toSqlNode(final Config sqlParserConfig) {
SqlParserPos.ZERO,
quantifier != null ? symbolLiteralOf(quantifier) : null));
} else if (operands.size() == 1 && quantifier == null) {
return applySpecialOperators(operandNodes(sqlParserConfig).get(0));
return applySpecialOperators(operandNodes(sqlParserConfig).getFirst());
} else {
throw new UnsupportedOperationException(String.format(
"Unsupported combination for QueryProjection: %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private SqlNode injectPredicates(final SqlCall call) {
} else if (call.getClass() == SqlOrderBy.class) {
final SqlOrderBy orderByNode = (SqlOrderBy) call;
// element of index 0 is the select node
selectNode = (SqlSelect) orderByNode.getOperandList().get(0);
selectNode = (SqlSelect) orderByNode.getOperandList().getFirst();
} else if (call.getClass() == SqlWith.class) {
final SqlWith withNode = (SqlWith) call;
// element of index 1 is the select node - in simple with + select queries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ public static SqlNode combinePredicates(final List<SqlNode> predicates) {
if (predicates.isEmpty()) {
return null;
} else if (predicates.size() == 1) {
return predicates.get(0);
return predicates.getFirst();
}
return addPredicates(predicates.get(0), predicates.subList(1, predicates.size()));
return addPredicates(predicates.getFirst(), predicates.subList(1, predicates.size()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void testPostProcessorOperatorWithCombinerResult() throws Exception {
private void assertLabelsAreCorrect(final OperatorResult r) {
for (final AnomalyDTO anomaly : r.getAnomalies()) {
assertThat(anomaly.getAnomalyLabels().size()).isEqualTo(1);
final AnomalyLabelDTO label = anomaly.getAnomalyLabels().get(0);
final AnomalyLabelDTO label = anomaly.getAnomalyLabels().getFirst();
assertThat(label.getName()).isEqualTo(TEST_POST_PROCESSOR_LABEL_NAME);
assertThat(label.getSourceNodeName()).isEqualTo(NODE_BEAN_NAME);
assertThat(label.getSourcePostProcessor()).isEqualTo(TEST_POST_PROCESSOR_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void beforeClass() throws Exception {
.setLastTimestamp(new Date())
.setTemplate(new AlertTemplateApi().setNodes(List.of(new PlanNodeApi()))))))
.readEntity(new GenericType<List<AlertApi>>() {})
.get(0)
.getFirst()
.getId();

final List<AnomalyApi> anomalies = new ArrayList<>();
Expand Down Expand Up @@ -144,7 +144,7 @@ public void testNegativeLimitValue() {
final StatusListApi results = response.readEntity(ERROR_LIST_TYPE);
assertThat(response.getStatus()).isEqualTo(400);
assertThat(results.getList()).isNotEmpty();
assertThat(results.getList().get(0).getCode()).isEqualTo(ERR_NEGATIVE_LIMIT_VALUE);
assertThat(results.getList().getFirst().getCode()).isEqualTo(ERR_NEGATIVE_LIMIT_VALUE);
}

@Test
Expand All @@ -153,7 +153,7 @@ public void testNegativeOffsetValue() {
final StatusListApi results = response.readEntity(ERROR_LIST_TYPE);
assertThat(response.getStatus()).isEqualTo(400);
assertThat(results.getList()).isNotEmpty();
assertThat(results.getList().get(0).getCode()).isEqualTo(ERR_NEGATIVE_OFFSET_VALUE);
assertThat(results.getList().getFirst().getCode()).isEqualTo(ERR_NEGATIVE_OFFSET_VALUE);
}

@Test
Expand All @@ -162,7 +162,7 @@ public void testOffsetWithoutLimit() {
final StatusListApi results = response.readEntity(ERROR_LIST_TYPE);
assertThat(response.getStatus()).isEqualTo(400);
assertThat(results.getList()).isNotEmpty();
assertThat(results.getList().get(0).getCode()).isEqualTo(ERR_OFFSET_WITHOUT_LIMIT);
assertThat(results.getList().getFirst().getCode()).isEqualTo(ERR_OFFSET_WITHOUT_LIMIT);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void setUpData() {
response = client.request("api/data-sources")
.post(Entity.json(List.of(pinotDataSourceApi)));
assert200(response);
final DataSourceApi dataSourceInResponse = response.readEntity(DATASOURCE_LIST_TYPE).get(0);
final DataSourceApi dataSourceInResponse = response.readEntity(DATASOURCE_LIST_TYPE).getFirst();
pinotDataSourceApi.setId(dataSourceInResponse.getId());

// create dataset
Expand All @@ -158,7 +158,7 @@ public void testCreateAlertLastTimestamp() {
.post(Entity.json(List.of(ALERT_API)));
assertThat(createResponse.getStatus()).isEqualTo(200);
final List<AlertApi> alerts = createResponse.readEntity(ALERT_LIST_TYPE);
alertId = alerts.get(0).getId();
alertId = alerts.getFirst().getId();

final AlertDTO alert = alertManager.findById(alertId);
final AlertTemplateDTO renderedTemplate = alertTemplateRenderer.renderAlert(alert);
Expand All @@ -182,7 +182,7 @@ public void testCreateSubscriptionGroup() {
try (final Response r = client.request("api/subscription-groups")
.post(Entity.json(List.of(SUBSCRIPTION_GROUP_API)))) {
assertThat(r.getStatus()).isEqualTo(200);
subscriptionGroupId = r.readEntity(SUBSCRIPTION_GROUP_LIST_TYPE).get(0).getId();
subscriptionGroupId = r.readEntity(SUBSCRIPTION_GROUP_LIST_TYPE).getFirst().getId();
}
}

Expand Down Expand Up @@ -231,7 +231,7 @@ public void testDailyFeb21() throws InterruptedException {
final NotificationPayloadApi notificationPayload = nsf.getNotificationPayload();
assertThat(notificationPayload.getAnomalyReports()).hasSize(1);

final AnomalyApi anomalyApi = notificationPayload.getAnomalyReports().get(0).getAnomaly();
final AnomalyApi anomalyApi = notificationPayload.getAnomalyReports().getFirst().getAnomaly();
assertThat(anomalyApi.getStartTime()).isEqualTo(new Date(epoch("2020-02-17 00:00")));
assertThat(anomalyApi.getEndTime()).isEqualTo(new Date(epoch("2020-02-21 00:00")));
}
Expand Down Expand Up @@ -296,7 +296,7 @@ public void testDailyMar4() throws InterruptedException {
final NotificationPayloadApi notificationPayload = nsf.getNotificationPayload();
assertThat(notificationPayload.getAnomalyReports()).hasSize(1);

final AnomalyApi anomalyApi = notificationPayload.getAnomalyReports().get(0).getAnomaly();
final AnomalyApi anomalyApi = notificationPayload.getAnomalyReports().getFirst().getAnomaly();
assertThat(anomalyApi.getStartTime()).isEqualTo(new Date(epoch("2020-03-02 00:00")));
assertThat(anomalyApi.getEndTime()).isEqualTo(new Date(epoch("2020-03-03 00:00")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void testCreatePinotDataSource() {
final Response response = request("api/data-sources").post(Entity.json(List.of(
pinotDataSourceApi)));
assert200(response);
final DataSourceApi dataSourceInResponse = response.readEntity(DATASOURCE_LIST_TYPE).get(0);
final DataSourceApi dataSourceInResponse = response.readEntity(DATASOURCE_LIST_TYPE).getFirst();
pinotDataSourceApi.setId(dataSourceInResponse.getId());

}
Expand Down Expand Up @@ -268,7 +268,7 @@ public void testCreateAlert() {

assert200(response);
final List<AlertApi> alerts = response.readEntity(ALERT_LIST_TYPE);
alertId = alerts.get(0).getId();
alertId = alerts.getFirst().getId();
UPDATE_ALERT_API.setId(alertId);
}

Expand Down Expand Up @@ -370,8 +370,8 @@ public void testUpdateAlert() throws InterruptedException {
final Response response = request("api/alerts").put(Entity.json(List.of(UPDATE_ALERT_API)));
assert200(response);
final List<AlertApi> alerts = response.readEntity(ALERT_LIST_TYPE);
assertThat(alerts.get(0).getId()).isEqualTo(alertId);
alertLastUpdateTime = alerts.get(0).getUpdated().getTime();
assertThat(alerts.getFirst().getId()).isEqualTo(alertId);
alertLastUpdateTime = alerts.getFirst().getUpdated().getTime();
}

@Test(dependsOnMethods = "testUpdateAlert", timeOut = 50000L)
Expand Down Expand Up @@ -748,7 +748,7 @@ private long mustCreateAlert(final AlertApi alertApi) {
final var response = request("api/alerts")
.post(Entity.json(List.of(alertApi)));
assertThat(response.getStatus()).isEqualTo(200);
final var gotApi = response.readEntity(new GenericType<List<AlertApi>>() {}).get(0);
final var gotApi = response.readEntity(new GenericType<List<AlertApi>>() {}).getFirst();
assertThat(gotApi).isNotNull();
assertThat(gotApi.getId()).isNotNull();
return gotApi.getId();
Expand All @@ -758,7 +758,7 @@ private long mustCreateInvestigation(final RcaInvestigationApi investigationApi)
final var response = request("api/rca/investigations")
.post(Entity.json(List.of(investigationApi)));
assertThat(response.getStatus()).isEqualTo(200);
final var gotApi = response.readEntity(new GenericType<List<RcaInvestigationApi>>() {}).get(0);
final var gotApi = response.readEntity(new GenericType<List<RcaInvestigationApi>>() {}).getFirst();
assertThat(gotApi).isNotNull();
assertThat(gotApi.getId()).isNotNull();
return gotApi.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void setUpData() {
response = client.request("api/data-sources")
.post(Entity.json(List.of(pinotDataSourceApi)));
assert200(response);
final DataSourceApi dataSourceInResponse = response.readEntity(DATASOURCE_LIST_TYPE).get(0);
final DataSourceApi dataSourceInResponse = response.readEntity(DATASOURCE_LIST_TYPE).getFirst();
pinotDataSourceApi.setId(dataSourceInResponse.getId());

// create dataset
Expand All @@ -133,7 +133,7 @@ public void testCreateAlertLastTimestamp() {
.post(Entity.json(List.of(ALERT_API)));
assertThat(createResponse.getStatus()).isEqualTo(200);
final List<AlertApi> alerts = createResponse.readEntity(ALERT_LIST_TYPE);
alertId = alerts.get(0).getId();
alertId = alerts.getFirst().getId();

// time advancing should not impact lastTimestamp
CLOCK.tick(5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void oauthSetup() throws Exception {
.issuer(ISSUER)
.expirationTime(new Date(System.currentTimeMillis() + 36000000))
.build();
oAuthToken = String.format("Bearer %s", getToken(jwks.getKeys().get(0), claimsSet));
oAuthToken = String.format("Bearer %s", getToken(jwks.getKeys().getFirst(), claimsSet));

dir = new File(DIR);
dir.mkdir();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public MetricConfigDTO findBy(final String metricName,
.stream().filter(d -> Objects.equals(d.namespace(), namespace)).toList();
if (CollectionUtils.isNotEmpty(list)) {
// TODO CYRIL behavior is different in AbstractManager#findUniqueByNameAndNamespace --> clarify
return list.get(0);
return list.getFirst();
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ AND ref_id not in (select ref_id from task_entity where status = 'RUNNING')
if (dtos.isEmpty()) {
return null;
}
return dtos.get(0);
return dtos.getFirst();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private EnumerationItemDTO findExistingOrCreate(final EnumerationItemDTO source,
return source;
} else if (matching.size() == 1) {
// already exists
return matching.get(0);
return matching.getFirst();
} else {
final List<Long> ids = matching.stream()
.map(EnumerationItemDTO::getId)
Expand All @@ -166,7 +166,7 @@ private EnumerationItemDTO findExistingOrCreate(final EnumerationItemDTO source,
ids);
// returning the first item of the list
// fixme cyril kept the existing behavior but we should throw an error - the system is in an inconsistent state
return matching.get(0);
return matching.getFirst();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public AbstractDTO getRaw(final Long id) {
if (genericJsonEntity != null) {
return toDto(genericJsonEntity,
SubEntities.BEAN_TYPE_MAP.asMultimap().inverse().get(
SubEntityType.valueOf(genericJsonEntity.getType())).asList().get(0));
SubEntityType.valueOf(genericJsonEntity.getType())).asList().getFirst());
}
} catch (final JsonProcessingException | SQLException e) {
LOG.error(e.getMessage(), e);
Expand Down
Loading