Skip to content

Commit

Permalink
Update spotless to run on Java 21
Browse files Browse the repository at this point in the history
This involves code formatting changes to comply with updated formatting
library.
  • Loading branch information
findepi committed Jun 11, 2024
1 parent 32f4434 commit 2a96267
Show file tree
Hide file tree
Showing 63 changed files with 213 additions and 71 deletions.
5 changes: 4 additions & 1 deletion api/src/main/java/org/apache/iceberg/DataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public interface DataFile extends ContentFile<DataFile> {
int PARTITION_ID = 102;
String PARTITION_NAME = "partition";
String PARTITION_DOC = "Partition data tuple, schema based on the partition spec";

// NEXT ID TO ASSIGN: 142

static StructType getType(StructType partitionType) {
Expand All @@ -126,7 +127,9 @@ static StructType getType(StructType partitionType) {
SORT_ORDER_ID);
}

/** @return the content stored in the file; one of DATA, POSITION_DELETES, or EQUALITY_DELETES */
/**
* @return the content stored in the file; one of DATA, POSITION_DELETES, or EQUALITY_DELETES
*/
@Override
default FileContent content() {
return FileContent.DATA;
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/org/apache/iceberg/SortOrderBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@ default R desc(Term term) {
default R caseSensitive(boolean caseSensitive) {
throw new UnsupportedOperationException(
this.getClass().getName() + " doesn't implement caseSensitive");
};
}
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import java.util.Map;

/** A minimum client interface to connect to a key management service (KMS). */
/** @deprecated the API will be removed in v2.0.0 (replaced with KeyManagementClient interface). */
/**
* @deprecated the API will be removed in v2.0.0 (replaced with KeyManagementClient interface).
*/
@Deprecated
public interface KmsClient extends Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ static <T> Truncate<T> get(int width) {
return new Truncate<>(width);
}

/** @deprecated will be removed in 2.0.0 */
/**
* @deprecated will be removed in 2.0.0
*/
@Deprecated
@SuppressWarnings("unchecked")
static <T, R extends Truncate<T> & SerializableFunction<T, T>> R get(Type type, int width) {
Expand Down
1 change: 1 addition & 0 deletions api/src/test/java/org/apache/iceberg/TestHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ public static <T> T deserialize(final InputStream inputStream)
return obj;
}
}

/**
* Serializes an {@link Object} to a byte array for storage/serialization.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ private int metadataFileCount(TableMetadata metadata) {
new File(S3TestUtil.getKeyFromUri(metadata.metadataFileLocation()))
.getParent())
.build())
.contents().stream()
.contents()
.stream()
.filter(s3Object -> s3Object.key().endsWith("metadata.json"))
.count();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,7 @@ public void testPrefixList() {
List<Integer> scaleSizes = Lists.newArrayList(1, 1000, 2500);
String listPrefix = String.format("s3://%s/%s/%s", bucketName, prefix, "prefix-list-test");

scaleSizes
.parallelStream()
scaleSizes.parallelStream()
.forEach(
scale -> {
String scalePrefix = String.format("%s/%s/", listPrefix, scale);
Expand All @@ -434,8 +433,7 @@ public void testPrefixDelete() {
String deletePrefix = String.format("s3://%s/%s/%s", bucketName, prefix, "prefix-delete-test");

List<Integer> scaleSizes = Lists.newArrayList(0, 5, 1000, 2500);
scaleSizes
.parallelStream()
scaleSizes.parallelStream()
.forEach(
scale -> {
String scalePrefix = String.format("%s/%s/", deletePrefix, scale);
Expand Down
12 changes: 12 additions & 0 deletions aws/src/main/java/org/apache/iceberg/aws/HttpClientProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class HttpClientProperties implements Serializable {
public static final String CLIENT_TYPE_APACHE = "apache";

private static final String CLIENT_PREFIX = "http-client.";

/**
* If this is set under {@link #CLIENT_TYPE}, {@link
* software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient} will be used as the HTTP
Expand All @@ -59,6 +60,7 @@ public class HttpClientProperties implements Serializable {
* software.amazon.awssdk.http.apache.ApacheHttpClient.Builder}
*/
public static final String PROXY_ENDPOINT = "http-client.proxy-endpoint";

/**
* Used to configure the connection timeout in milliseconds for {@link
* software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient.Builder}. This flag only
Expand All @@ -69,6 +71,7 @@ public class HttpClientProperties implements Serializable {
*/
public static final String URLCONNECTION_CONNECTION_TIMEOUT_MS =
"http-client.urlconnection.connection-timeout-ms";

/**
* Used to configure the socket timeout in milliseconds for {@link
* software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient.Builder}. This flag only
Expand All @@ -79,6 +82,7 @@ public class HttpClientProperties implements Serializable {
*/
public static final String URLCONNECTION_SOCKET_TIMEOUT_MS =
"http-client.urlconnection.socket-timeout-ms";

/**
* Used to configure the connection timeout in milliseconds for {@link
* software.amazon.awssdk.http.apache.ApacheHttpClient.Builder}. This flag only works when {@link
Expand All @@ -89,6 +93,7 @@ public class HttpClientProperties implements Serializable {
*/
public static final String APACHE_CONNECTION_TIMEOUT_MS =
"http-client.apache.connection-timeout-ms";

/**
* Used to configure the socket timeout in milliseconds for {@link
* software.amazon.awssdk.http.apache.ApacheHttpClient.Builder}. This flag only works when {@link
Expand All @@ -98,6 +103,7 @@ public class HttpClientProperties implements Serializable {
* https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/http/apache/ApacheHttpClient.Builder.html
*/
public static final String APACHE_SOCKET_TIMEOUT_MS = "http-client.apache.socket-timeout-ms";

/**
* Used to configure the connection acquisition timeout in milliseconds for {@link
* software.amazon.awssdk.http.apache.ApacheHttpClient.Builder}. This flag only works when {@link
Expand All @@ -108,6 +114,7 @@ public class HttpClientProperties implements Serializable {
*/
public static final String APACHE_CONNECTION_ACQUISITION_TIMEOUT_MS =
"http-client.apache.connection-acquisition-timeout-ms";

/**
* Used to configure the connection max idle time in milliseconds for {@link
* software.amazon.awssdk.http.apache.ApacheHttpClient.Builder}. This flag only works when {@link
Expand All @@ -118,6 +125,7 @@ public class HttpClientProperties implements Serializable {
*/
public static final String APACHE_CONNECTION_MAX_IDLE_TIME_MS =
"http-client.apache.connection-max-idle-time-ms";

/**
* Used to configure the connection time to live in milliseconds for {@link
* software.amazon.awssdk.http.apache.ApacheHttpClient.Builder}. This flag only works when {@link
Expand All @@ -128,6 +136,7 @@ public class HttpClientProperties implements Serializable {
*/
public static final String APACHE_CONNECTION_TIME_TO_LIVE_MS =
"http-client.apache.connection-time-to-live-ms";

/**
* Used to configure whether to enable the expect continue setting for {@link
* software.amazon.awssdk.http.apache.ApacheHttpClient.Builder}. This flag only works when {@link
Expand All @@ -140,6 +149,7 @@ public class HttpClientProperties implements Serializable {
*/
public static final String APACHE_EXPECT_CONTINUE_ENABLED =
"http-client.apache.expect-continue-enabled";

/**
* Used to configure the max connections number for {@link
* software.amazon.awssdk.http.apache.ApacheHttpClient.Builder}. This flag only works when {@link
Expand All @@ -149,6 +159,7 @@ public class HttpClientProperties implements Serializable {
* https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/http/apache/ApacheHttpClient.Builder.html
*/
public static final String APACHE_MAX_CONNECTIONS = "http-client.apache.max-connections";

/**
* Used to configure whether to enable the tcp keep alive setting for {@link
* software.amazon.awssdk.http.apache.ApacheHttpClient.Builder}. This flag only works when {@link
Expand All @@ -161,6 +172,7 @@ public class HttpClientProperties implements Serializable {
*/
public static final String APACHE_TCP_KEEP_ALIVE_ENABLED =
"http-client.apache.tcp-keep-alive-enabled";

/**
* Used to configure whether to use idle connection reaper for {@link
* software.amazon.awssdk.http.apache.ApacheHttpClient.Builder}. This flag only works when {@link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public interface S3FileIOAwsClientFactory extends Serializable {
* @return s3 client
*/
S3Client s3();

/**
* Initialize AWS client factory from catalog properties.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ public void testPrefixList() {

List<Integer> scaleSizes = Lists.newArrayList(1, 1000, 2500);

scaleSizes
.parallelStream()
scaleSizes.parallelStream()
.forEach(
scale -> {
String scalePrefix = String.format("%s/%s/", prefix, scale);
Expand Down
8 changes: 5 additions & 3 deletions baseline.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ subprojects {
apply plugin: 'com.palantir.baseline-reproducibility'
apply plugin: 'com.palantir.baseline-exact-dependencies'
apply plugin: 'com.palantir.baseline-release-compatibility'
apply plugin: 'com.diffplug.spotless'
// Google Java Format changed the rules since the last version supporting Java 8, so skip the check when using 8.
if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
apply plugin: 'com.diffplug.spotless'
}

pluginManager.withPlugin('com.palantir.baseline-checkstyle') {
checkstyle {
Expand All @@ -60,8 +63,7 @@ subprojects {
spotless {
java {
target 'src/main/java/**/*.java', 'src/test/java/**/*.java', 'src/jmh/java/**/*.java', 'src/integration/java/**/*.java'
// we use an older version of google-java-format that is compatible with JDK 8
googleJavaFormat("1.7")
googleJavaFormat("1.17.0")
removeUnusedImports()
licenseHeaderFile "$rootDir/.baseline/copyright/copyright-header-java.txt"
}
Expand Down
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ buildscript {
// in an old version of the errorprone, which doesn't work w/ Gradle 8, so bump errorpone as
// well.
classpath "net.ltgt.gradle:gradle-errorprone-plugin:3.1.0"

classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.13.0'
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
// Spotless 6.13 is last version working with Java 8 https://github.com/diffplug/spotless/blob/main/plugin-gradle/CHANGES.md#6140---2023-01-26
// The Spotless plugin is not run on Java 8, but it needs to load at least.
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.13.0'
} else {
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.25.0'
}
classpath 'gradle.plugin.org.inferred:gradle-processors:3.7.0'
classpath 'me.champeau.jmh:jmh-gradle-plugin:0.7.2'
classpath 'gradle.plugin.io.morethan.jmhreport:gradle-jmh-report:0.9.6'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ private CatalogProperties() {}
"client.pool.cache.eviction-interval-ms";
public static final long CLIENT_POOL_CACHE_EVICTION_INTERVAL_MS_DEFAULT =
TimeUnit.MINUTES.toMillis(5);

/**
* A comma separated list of elements used, in addition to the {@link #URI}, to compose the key of
* the client pool cache.
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/apache/iceberg/DataFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ public Builder withSplitOffsets(List<Long> offsets) {
return this;
}

/** @deprecated since 1.5.0, will be removed in 1.6.0; must not be set for data files. */
/**
* @deprecated since 1.5.0, will be removed in 1.6.0; must not be set for data files.
*/
@Deprecated
public Builder withEqualityFieldIds(List<Integer> equalityIds) {
throw new UnsupportedOperationException("Equality field IDs must not be set for data files");
Expand Down
12 changes: 9 additions & 3 deletions core/src/main/java/org/apache/iceberg/GenericManifestEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,17 @@ ManifestEntry<F> wrapDelete(
return this;
}

/** @return the status of the file, whether EXISTING, ADDED, or DELETED */
/**
* @return the status of the file, whether EXISTING, ADDED, or DELETED
*/
@Override
public Status status() {
return status;
}

/** @return id of the snapshot in which the file was added to the table */
/**
* @return id of the snapshot in which the file was added to the table
*/
@Override
public Long snapshotId() {
return snapshotId;
Expand All @@ -116,7 +120,9 @@ public Long fileSequenceNumber() {
return fileSequenceNumber;
}

/** @return a file */
/**
* @return a file
*/
@Override
public F file() {
return file;
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/apache/iceberg/ManifestEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public int id() {
Types.NestedField FILE_SEQUENCE_NUMBER =
optional(4, "file_sequence_number", Types.LongType.get());
int DATA_FILE_ID = 2;

// next ID to assign: 5

static Schema getSchema(StructType partitionType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ private void invalidateFilteredCache() {
cleanUncommitted(SnapshotProducer.EMPTY_SET);
}

/** @return a ManifestReader that is a filtered version of the input manifest. */
/**
* @return a ManifestReader that is a filtered version of the input manifest.
*/
private ManifestFile filterManifest(Schema tableSchema, ManifestFile manifest) {
ManifestFile cached = filteredManifests.get(manifest);
if (cached != null) {
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/apache/iceberg/ManifestReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ private boolean isLiveEntry(ManifestEntry<F> entry) {
return entry != null && entry.status() != ManifestEntry.Status.DELETED;
}

/** @return an Iterator of DataFile. Makes defensive copies of files before returning */
/**
* @return an Iterator of DataFile. Makes defensive copies of files before returning
*/
@Override
public CloseableIterator<F> iterator() {
boolean dropStats = dropStats(columns);
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/apache/iceberg/SystemConfigs.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ private SystemConfigs() {}
8,
Integer::parseUnsignedInt);

/** @deprecated will be removed in 2.0.0; use name mapping instead */
/**
* @deprecated will be removed in 2.0.0; use name mapping instead
*/
@Deprecated
public static final ConfigEntry<Boolean> NETFLIX_UNSAFE_PARQUET_ID_FALLBACK_ENABLED =
new ConfigEntry<>(
Expand Down
16 changes: 12 additions & 4 deletions core/src/main/java/org/apache/iceberg/TableProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,16 @@ private TableProperties() {}
public static final String OBJECT_STORE_ENABLED = "write.object-storage.enabled";
public static final boolean OBJECT_STORE_ENABLED_DEFAULT = false;

/** @deprecated Use {@link #WRITE_DATA_LOCATION} instead. */
/**
* @deprecated Use {@link #WRITE_DATA_LOCATION} instead.
*/
@Deprecated public static final String OBJECT_STORE_PATH = "write.object-storage.path";

public static final String WRITE_LOCATION_PROVIDER_IMPL = "write.location-provider.impl";

/** @deprecated Use {@link #WRITE_DATA_LOCATION} instead. */
/**
* @deprecated Use {@link #WRITE_DATA_LOCATION} instead.
*/
@Deprecated
public static final String WRITE_FOLDER_STORAGE_LOCATION = "write.folder-storage.path";

Expand All @@ -266,10 +270,14 @@ private TableProperties() {}
public static final String WRITE_PARTITION_SUMMARY_LIMIT = "write.summary.partition-limit";
public static final int WRITE_PARTITION_SUMMARY_LIMIT_DEFAULT = 0;

/** @deprecated will be removed in 2.0.0, writing manifest lists is always enabled */
/**
* @deprecated will be removed in 2.0.0, writing manifest lists is always enabled
*/
@Deprecated public static final String MANIFEST_LISTS_ENABLED = "write.manifest-lists.enabled";

/** @deprecated will be removed in 2.0.0, writing manifest lists is always enabled */
/**
* @deprecated will be removed in 2.0.0, writing manifest lists is always enabled
*/
@Deprecated public static final boolean MANIFEST_LISTS_ENABLED_DEFAULT = true;

public static final String METADATA_COMPRESSION = "write.metadata.compression-codec";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public class PlaintextEncryptionManager implements EncryptionManager {
private static final EncryptionManager INSTANCE = new PlaintextEncryptionManager();
private static final Logger LOG = LoggerFactory.getLogger(PlaintextEncryptionManager.class);

/** @deprecated will be removed in 1.6.0. use {@link #instance()} instead. */
/**
* @deprecated will be removed in 1.6.0. use {@link #instance()} instead.
*/
@Deprecated
public PlaintextEncryptionManager() {}

Expand Down
Loading

0 comments on commit 2a96267

Please sign in to comment.