Skip to content

Commit

Permalink
Build: enforce & apply spotless on 1.0.x
Browse files Browse the repository at this point in the history
With JDK8: ./gradlew spotlessApply -DflinkVersions=1.13,1.14,1.15 -DsparkVersions=2.4,3.0,3.1,3.2,3.3 -DhiveVersions=2,3 --no-build-cache
  • Loading branch information
nastra committed Sep 29, 2022
1 parent 71d918e commit 5e7cfff
Show file tree
Hide file tree
Showing 3,077 changed files with 158,964 additions and 123,788 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
59 changes: 0 additions & 59 deletions .baseline/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
<property name="severity" value="error"/>

<module name="FileTabCharacter"/> <!-- Java Style Guide: Whitespace characters -->
<module name="LineLength"> <!-- Java Style Guide: No line-wrapping -->
<property name="max" value="120"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="NewlineAtEndOfFile"> <!-- Java Style Guide: Line ending: LF -->
<property name="lineSeparator" value="lf"/>
</module>
Expand Down Expand Up @@ -148,10 +144,6 @@
<property name="exceptionVariableName" value="expected"/>
</module>
<module name="EmptyForInitializerPad"/> <!-- Java Style Guide: Horizontal whitespace -->
<module name="EmptyLineSeparator"> <!-- Java Style Guide: Source file structure -->
<property name="tokens" value="PACKAGE_DEF, IMPORT, CLASS_DEF, ENUM_DEF, INTERFACE_DEF, CTOR_DEF, STATIC_INIT, INSTANCE_INIT, VARIABLE_DEF"/>
<property name="allowNoEmptyLineBetweenFields" value="true"/>
</module>
<module name="EmptyStatement"/> <!-- Java Style Guide: One statement per line -->
<module name="EqualsHashCode"/>
<module name="FallThrough"/> <!-- Java Style Guide: Fall-through: commented -->
Expand Down Expand Up @@ -255,20 +247,7 @@
<property name="illegalClassNames" value="com.google.common.cache.CacheBuilder, com.google.common.cache.Cache, com.google.common.cache.LoadingCache"/>
<message key="illegal.type" value="Do not use Guava caches, they are outperformed by and harder to use than Caffeine caches"/>
</module>
<module name="ImportOrder"> <!-- Java Style Guide: Ordering and spacing -->
<property name="groups" value="/.*/"/>
<property name="option" value="bottom"/>
<property name="separated" value="true"/>
<property name="sortStaticImportsAlphabetically" value="true"/>
</module>
<module name="Indentation"> <!-- Java Style Guide: Block indentation: +4 spaces -->
<property name="basicOffset" value="2"/>
<property name="arrayInitIndent" value="4"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="caseIndent" value="2"/>
</module>
<module name="InnerAssignment"/> <!-- Java Coding Guidelines: Inner assignments: Not used -->
<module name="LeftCurly"/> <!-- Java Style Guide: Nonempty blocks: K & R style -->
<module name="MemberName"> <!-- Java Style Guide: Non-constant field names -->
<property name="format" value="^[a-z][a-zA-Z0-9]+$"/>
<message key="name.invalidPattern" value="Member name ''{0}'' must match pattern ''{1}''."/>
Expand All @@ -287,19 +266,8 @@
<module name="NoClone"/> <!-- Java Coding Guidelines: Never override Object#finalize or Object#clone -->
<module name="NoFinalizer"/> <!-- Java Coding Guidelines: Never override Object#finalize -->
<module name="NoLineWrap"/> <!-- Java Style Guide: No line-wrapping -->
<module name="NoWhitespaceAfter"> <!-- Java Style Guide: Horizontal whitespace -->
<property name="allowLineBreaks" value="false"/>
<property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
</module>
<module name="NoWhitespaceBefore"> <!-- Java Style Guide: Horizontal whitespace -->
<property name="allowLineBreaks" value="true"/>
</module>
<module name="OneStatementPerLine"/> <!-- Java Style Guide: One statement per line -->
<module name="OneTopLevelClass"/> <!-- Java Style Guide: Exactly one top-level class declaration -->
<module name="OperatorWrap"> <!-- Java Style Guide: Where to break -->
<property name="option" value="EOL"/>
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
</module>
<module name="OuterTypeFilename"/> <!-- Java Style Guide: File name -->
<module name="PackageAnnotation"/> <!-- Java Style Guide: Package statement -->
<module name="PackageDeclaration"/> <!-- Java Style Guide: Package statement -->
Expand Down Expand Up @@ -410,22 +378,6 @@
<property name="format" value="(void setUp\(\))|(void setup\(\))|(void setupStatic\(\))|(void setUpStatic\(\))|(void beforeTest\(\))|(void teardown\(\))|(void tearDown\(\))|(void beforeStatic\(\))|(void afterStatic\(\))"/>
<property name="message" value="Test setup/teardown methods are called before(), beforeClass(), after(), afterClass(), but not setUp, teardown, etc."/>
</module>
<module name="RightCurly"> <!-- Java Style Guide: Nonempty blocks: K & R style -->
<property name="option" value="same"/>
<property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_DO"/>
</module>
<module name="RightCurly"> <!-- Java Style Guide: Nonempty blocks: K & R style -->
<property name="option" value="alone"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="SeparatorWrap"> <!-- Java Style Guide: Where to break -->
<property name="tokens" value="DOT"/>
<property name="option" value="nl"/>
</module>
<module name="SeparatorWrap"> <!-- Java Style Guide: Where to break -->
<property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/>
</module>
<module name="SimplifyBooleanExpression"/> <!-- Java Coding Guidelines: Keep Boolean expressions simple -->
<module name="SimplifyBooleanReturn"/> <!-- Java Coding Guidelines: Keep Boolean expressions simple -->
<module name="StaticVariableName"/> <!-- Java Style Guide: Naming -->
Expand All @@ -448,16 +400,6 @@
</module>
<module name="UpperEll"/> <!-- Java Style Guide: Numeric Literals -->
<module name="VisibilityModifier"/> <!-- Java Coding Guidelines: Minimize mutability -->
<module name="WhitespaceAfter"/> <!-- Java Style Guide: Horizontal whitespace -->
<module name="WhitespaceAround"> <!-- Java Style Guide: Horizontal whitespace -->
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<property name="ignoreEnhancedForColon" value="false"/>
<message key="ws.notFollowed" value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
<message key="ws.notPreceded" value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
</module>

<!-- Stricter checks begin: delete some or all of the following for faster prototyping, but please restore before pushing to production. -->

Expand Down Expand Up @@ -505,7 +447,6 @@
<message key="name.invalidPattern" value="Parameter name ''{0}'' must match pattern ''{1}''."/>
<property name="ignoreOverridden" value="true"/>
</module>
<module name="SingleLineJavadoc"/> <!-- Java Style Guide: General form -->

<!-- Stricter checks end -->
</module>
Expand Down
18 changes: 18 additions & 0 deletions .baseline/copyright/copyright-header-java.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iceberg.aliyun;

import com.aliyun.oss.OSS;
Expand All @@ -28,43 +27,52 @@

public class AliyunClientFactories {

private static final AliyunClientFactory ALIYUN_CLIENT_FACTORY_DEFAULT = new DefaultAliyunClientFactory();
private static final AliyunClientFactory ALIYUN_CLIENT_FACTORY_DEFAULT =
new DefaultAliyunClientFactory();

private AliyunClientFactories() {
}
private AliyunClientFactories() {}

public static AliyunClientFactory defaultFactory() {
return ALIYUN_CLIENT_FACTORY_DEFAULT;
}

public static AliyunClientFactory from(Map<String, String> properties) {
String factoryImpl = PropertyUtil.propertyAsString(
properties, AliyunProperties.CLIENT_FACTORY, DefaultAliyunClientFactory.class.getName());
String factoryImpl =
PropertyUtil.propertyAsString(
properties,
AliyunProperties.CLIENT_FACTORY,
DefaultAliyunClientFactory.class.getName());
return loadClientFactory(factoryImpl, properties);
}

/**
* Load an implemented {@link AliyunClientFactory} based on the class name, and initialize it.
*
* @param impl the class name.
* @param impl the class name.
* @param properties to initialize the factory.
* @return an initialized {@link AliyunClientFactory}.
*/
private static AliyunClientFactory loadClientFactory(String impl, Map<String, String> properties) {
private static AliyunClientFactory loadClientFactory(
String impl, Map<String, String> properties) {
DynConstructors.Ctor<AliyunClientFactory> ctor;
try {
ctor = DynConstructors.builder(AliyunClientFactory.class).hiddenImpl(impl).buildChecked();
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(String.format(
"Cannot initialize AliyunClientFactory, missing no-arg constructor: %s", impl), e);
throw new IllegalArgumentException(
String.format(
"Cannot initialize AliyunClientFactory, missing no-arg constructor: %s", impl),
e);
}

AliyunClientFactory factory;
try {
factory = ctor.newInstance();
} catch (ClassCastException e) {
throw new IllegalArgumentException(
String.format("Cannot initialize AliyunClientFactory, %s does not implement AliyunClientFactory.", impl), e);
String.format(
"Cannot initialize AliyunClientFactory, %s does not implement AliyunClientFactory.",
impl),
e);
}

factory.initialize(properties);
Expand All @@ -74,16 +82,19 @@ private static AliyunClientFactory loadClientFactory(String impl, Map<String, St
static class DefaultAliyunClientFactory implements AliyunClientFactory {
private AliyunProperties aliyunProperties;

DefaultAliyunClientFactory() {
}
DefaultAliyunClientFactory() {}

@Override
public OSS newOSSClient() {
Preconditions.checkNotNull(
aliyunProperties, "Cannot create aliyun oss client before initializing the AliyunClientFactory.");

return new OSSClientBuilder().build(
aliyunProperties.ossEndpoint(), aliyunProperties.accessKeyId(), aliyunProperties.accessKeySecret());
aliyunProperties,
"Cannot create aliyun oss client before initializing the AliyunClientFactory.");

return new OSSClientBuilder()
.build(
aliyunProperties.ossEndpoint(),
aliyunProperties.accessKeyId(),
aliyunProperties.accessKeySecret());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iceberg.aliyun;

import com.aliyun.oss.OSS;
Expand All @@ -39,8 +38,6 @@ public interface AliyunClientFactory extends Serializable {
*/
void initialize(Map<String, String> properties);

/**
* Returns an initialized {@link AliyunProperties}
*/
/** Returns an initialized {@link AliyunProperties} */
AliyunProperties aliyunProperties();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iceberg.aliyun;

import java.io.Serializable;
Expand All @@ -26,41 +25,43 @@

public class AliyunProperties implements Serializable {
/**
* The domain name used to access OSS. OSS uses HTTP Restful APIs to provide services. Different regions are accessed
* by using different endpoints. For the same region, access over the internal network or over the Internet also uses
* different endpoints. For more information, see:
* The domain name used to access OSS. OSS uses HTTP Restful APIs to provide services. Different
* regions are accessed by using different endpoints. For the same region, access over the
* internal network or over the Internet also uses different endpoints. For more information, see:
* https://www.alibabacloud.com/help/doc-detail/31837.htm
*/
public static final String OSS_ENDPOINT = "oss.endpoint";

/**
* Aliyun uses an AccessKey pair, which includes an AccessKey ID and an AccessKey secret to implement symmetric
* encryption and verify the identity of a requester. The AccessKey ID is used to identify a user.
* <p>
* For more information about how to obtain an AccessKey pair, see:
* Aliyun uses an AccessKey pair, which includes an AccessKey ID and an AccessKey secret to
* implement symmetric encryption and verify the identity of a requester. The AccessKey ID is used
* to identify a user.
*
* <p>For more information about how to obtain an AccessKey pair, see:
* https://www.alibabacloud.com/help/doc-detail/53045.htm
*/
public static final String CLIENT_ACCESS_KEY_ID = "client.access-key-id";

/**
* Aliyun uses an AccessKey pair, which includes an AccessKey ID and an AccessKey secret to implement symmetric
* encryption and verify the identity of a requester. The AccessKey secret is used to encrypt and verify the
* signature string.
* <p>
* For more information about how to obtain an AccessKey pair, see:
* Aliyun uses an AccessKey pair, which includes an AccessKey ID and an AccessKey secret to
* implement symmetric encryption and verify the identity of a requester. The AccessKey secret is
* used to encrypt and verify the signature string.
*
* <p>For more information about how to obtain an AccessKey pair, see:
* https://www.alibabacloud.com/help/doc-detail/53045.htm
*/
public static final String CLIENT_ACCESS_KEY_SECRET = "client.access-key-secret";

/**
* The implementation class of {@link AliyunClientFactory} to customize Aliyun client configurations.
* If set, all Aliyun clients will be initialized by the specified factory.
* If not set, {@link AliyunClientFactories#defaultFactory()} is used as default factory.
* The implementation class of {@link AliyunClientFactory} to customize Aliyun client
* configurations. If set, all Aliyun clients will be initialized by the specified factory. If not
* set, {@link AliyunClientFactories#defaultFactory()} is used as default factory.
*/
public static final String CLIENT_FACTORY = "client.factory-impl";

/**
* Location to put staging files for uploading to OSS, defaults to the directory value of java.io.tmpdir.
* Location to put staging files for uploading to OSS, defaults to the directory value of
* java.io.tmpdir.
*/
public static final String OSS_STAGING_DIRECTORY = "oss.staging-dir";

Expand All @@ -79,8 +80,9 @@ public AliyunProperties(Map<String, String> properties) {
this.accessKeyId = properties.get(CLIENT_ACCESS_KEY_ID);
this.accessKeySecret = properties.get(CLIENT_ACCESS_KEY_SECRET);

this.ossStagingDirectory = PropertyUtil.propertyAsString(properties, OSS_STAGING_DIRECTORY,
System.getProperty("java.io.tmpdir"));
this.ossStagingDirectory =
PropertyUtil.propertyAsString(
properties, OSS_STAGING_DIRECTORY, System.getProperty("java.io.tmpdir"));
}

public String ossEndpoint() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iceberg.aliyun.oss;

import com.aliyun.oss.OSS;
Expand Down Expand Up @@ -62,8 +61,8 @@ public boolean exists() {
return objectMetadata() != null;
} catch (OSSException e) {

if (e.getErrorCode().equals(OSSErrorCode.NO_SUCH_BUCKET) ||
e.getErrorCode().equals(OSSErrorCode.NO_SUCH_KEY)) {
if (e.getErrorCode().equals(OSSErrorCode.NO_SUCH_BUCKET)
|| e.getErrorCode().equals(OSSErrorCode.NO_SUCH_KEY)) {
return false;
}

Expand All @@ -85,8 +84,6 @@ protected MetricsContext metrics() {

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("file", uri)
.toString();
return MoreObjects.toStringHelper(this).add("file", uri).toString();
}
}
Loading

0 comments on commit 5e7cfff

Please sign in to comment.