Skip to content

Commit 1873433

Browse files
committed
Merge remote-tracking branch 'apache/main' into trivy-cve-scan-kafka-connect
2 parents 0264d75 + 3e56b52 commit 1873433

7 files changed

Lines changed: 112 additions & 7 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ jobs:
4646
persist-credentials: false
4747

4848
- name: Initialize CodeQL
49-
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # v4
49+
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
5050
with:
5151
languages: actions
5252

5353
- name: Perform CodeQL Analysis
54-
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v4
54+
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
5555
with:
5656
category: "/language:actions"

core/src/main/java/org/apache/iceberg/EntryStatus.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ enum EntryStatus {
2626
/** Indicates an entry that has been replaced by a column update or DV change. Added in v4. */
2727
REPLACED(3);
2828

29+
private static final EntryStatus[] VALUES = EntryStatus.values();
30+
2931
private final int id;
3032

3133
EntryStatus(int id) {
@@ -35,4 +37,8 @@ enum EntryStatus {
3537
public int id() {
3638
return id;
3739
}
40+
41+
static EntryStatus fromId(int id) {
42+
return VALUES[id];
43+
}
3844
}

core/src/main/java/org/apache/iceberg/GenericManifestEntry.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
class GenericManifestEntry<F extends ContentFile<F>>
2828
implements ManifestEntry<F>, IndexedRecord, SpecificData.SchemaConstructable, StructLike {
29-
private static final Status[] STATUS_VALUES = Status.values();
3029
private final org.apache.avro.Schema schema;
3130
private Status status = Status.EXISTING;
3231
private Long snapshotId = null;
@@ -159,7 +158,7 @@ public void setFileSequenceNumber(long newFileSequenceNumber) {
159158
public void put(int i, Object v) {
160159
switch (i) {
161160
case 0:
162-
this.status = STATUS_VALUES[(Integer) v];
161+
this.status = Status.fromId((Integer) v);
163162
return;
164163
case 1:
165164
this.snapshotId = (Long) v;

core/src/main/java/org/apache/iceberg/GenericManifestFile.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public class GenericManifestFile extends SupportsIndexProjection
4040
implements ManifestFile, StructLike, IndexedRecord, SchemaConstructable, Serializable {
4141
private static final Schema AVRO_SCHEMA =
4242
AvroSchemaUtil.convert(ManifestFile.schema(), "manifest_file");
43-
private static final ManifestContent[] MANIFEST_CONTENT_VALUES = ManifestContent.values();
44-
4543
private transient Schema avroSchema; // not final for Java serialization
4644

4745
// data fields
@@ -343,7 +341,7 @@ protected <T> void internalSet(int basePos, T value) {
343341
return;
344342
case 3:
345343
this.content =
346-
value != null ? MANIFEST_CONTENT_VALUES[(Integer) value] : ManifestContent.DATA;
344+
value != null ? ManifestContent.fromId((Integer) value) : ManifestContent.DATA;
347345
return;
348346
case 4:
349347
this.sequenceNumber = value != null ? (Long) value : 0;

core/src/main/java/org/apache/iceberg/ManifestEntry.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ enum Status {
3030
ADDED(1),
3131
DELETED(2);
3232

33+
private static final Status[] VALUES = Status.values();
34+
3335
private final int id;
3436

3537
Status(int id) {
@@ -39,6 +41,10 @@ enum Status {
3941
public int id() {
4042
return id;
4143
}
44+
45+
static Status fromId(int id) {
46+
return VALUES[id];
47+
}
4248
}
4349

4450
// ids for data-file columns are assigned from 1000
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.iceberg;
20+
21+
import static org.assertj.core.api.Assertions.assertThat;
22+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
23+
24+
import java.util.stream.IntStream;
25+
import org.junit.jupiter.params.ParameterizedTest;
26+
import org.junit.jupiter.params.provider.EnumSource;
27+
import org.junit.jupiter.params.provider.MethodSource;
28+
29+
class TestEntryStatus {
30+
31+
@ParameterizedTest
32+
@EnumSource(EntryStatus.class)
33+
void fromId(EntryStatus status) {
34+
assertThat(EntryStatus.fromId(status.id())).isEqualTo(status);
35+
}
36+
37+
static IntStream invalidIds() {
38+
return IntStream.of(-1, EntryStatus.values().length);
39+
}
40+
41+
@ParameterizedTest
42+
@MethodSource("invalidIds")
43+
void fromIdInvalid(int id) {
44+
assertThatThrownBy(() -> EntryStatus.fromId(id))
45+
.isInstanceOf(ArrayIndexOutOfBoundsException.class)
46+
.hasMessageContaining(String.valueOf(id));
47+
}
48+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.iceberg;
20+
21+
import static org.assertj.core.api.Assertions.assertThat;
22+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
23+
24+
import java.util.stream.IntStream;
25+
import org.junit.jupiter.params.ParameterizedTest;
26+
import org.junit.jupiter.params.provider.EnumSource;
27+
import org.junit.jupiter.params.provider.MethodSource;
28+
29+
class TestManifestEntryStatus {
30+
31+
@ParameterizedTest
32+
@EnumSource(ManifestEntry.Status.class)
33+
void fromId(ManifestEntry.Status status) {
34+
assertThat(ManifestEntry.Status.fromId(status.id())).isEqualTo(status);
35+
}
36+
37+
static IntStream invalidIds() {
38+
return IntStream.of(-1, ManifestEntry.Status.values().length);
39+
}
40+
41+
@ParameterizedTest
42+
@MethodSource("invalidIds")
43+
void fromIdInvalid(int id) {
44+
assertThatThrownBy(() -> ManifestEntry.Status.fromId(id))
45+
.isInstanceOf(ArrayIndexOutOfBoundsException.class)
46+
.hasMessageContaining(String.valueOf(id));
47+
}
48+
}

0 commit comments

Comments
 (0)