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

Yingjianw/JDK 17 Upgrade #620

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/nebula-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# test against JDK 8
java: [ 8 ]
# test against JDK 17
java: [ 17 ]
name: CI with Java ${{ matrix.java }}
steps:
- uses: actions/checkout@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nebula-pr-functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# test against JDK 8
java: [ 8 ]
# test against JDK 17
java: [ 17 ]
name: Functional tests with Java ${{ matrix.java }}
steps:
- uses: actions/checkout@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nebula-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup jdk 8
- name: Setup jdk 17
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 17
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nebula-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# test against JDK 8
java: [ 8 ]
# test against JDK 17
java: [ 17 ]
name: CI with Java ${{ matrix.java }}
steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nebula-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 17
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
Expand Down
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ allprojects {

idea {
project {
jdkName = "8"
languageLevel = "8"
jdkName = "17"
languageLevel = "17"
vcs = "Git"
}
}
Expand All @@ -98,8 +98,8 @@ configure(javaProjects) {

group = "com.netflix.${githubProjectName}"

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

dependencyManagement {
imports {
Expand Down Expand Up @@ -251,6 +251,7 @@ configure(javaProjects) {
exceptionFormat = "full"
events "PASSED", "FAILED", "SKIPPED"
}
jvmArgs('--add-opens=java.base/java.lang.invoke=ALL-UNNAMED')
}

javadoc {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Used in documentation and for including the Gradle plugin
spring_boot_version=2.7.11
spring_cloud_version=Hoxton.SR8
google_guice_version=4.1.0
google_guice_version=5.1.0
spock_version=2.1-groovy-3.0

## Override Spring Boot versions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want javax.annotation.Nullable (jakarta when we move to SBN3)


import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
*/
package com.netflix.metacat.common.type;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import java.util.List;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

Expand All @@ -41,7 +41,7 @@ public final class TypeRegistry implements TypeManager {
* Constructor.
*/
private TypeRegistry() {
Preconditions.checkNotNull(types, "types is null");
Objects.requireNonNull(types, "types is null");
addType(BaseType.UNKNOWN);
addType(BaseType.BIGINT);
addType(BaseType.BOOLEAN);
Expand Down Expand Up @@ -80,7 +80,7 @@ public static TypeRegistry getTypeRegistry() {
* @param type parameter
*/
public static void verifyTypeClass(final Type type) {
Preconditions.checkNotNull(type, "type is null");
Objects.requireNonNull(type, "types is null");
}

/**
Expand Down Expand Up @@ -121,9 +121,11 @@ private Type instantiateParametricType(final TypeSignature signature) {
}
final Type instantiatedType = parametricType.createType(parameterTypes.build(),
signature.getLiteralParameters());
Preconditions.checkState(instantiatedType.getTypeSignature().equals(signature),
"Instantiated parametric type name (%s) does not match expected name (%s)",
instantiatedType, signature);
if (!instantiatedType.getTypeSignature().equals(signature)) {
throw new IllegalStateException(String.format(
"Instantiated parametric type name (%s) does not match expected name (%s)",
instantiatedType, signature));
}
return instantiatedType;
}

Expand All @@ -135,8 +137,9 @@ private Type instantiateParametricType(final TypeSignature signature) {
public void addType(final Type type) {
verifyTypeClass(type);
final Type existingType = types.putIfAbsent(type.getTypeSignature(), type);
Preconditions.checkState(existingType == null
|| existingType.equals(type), "Type %s is already registered", type);
if (!(existingType == null || existingType.equals(type))) {
throw new IllegalStateException(String.format("Type %s is already registered", type));
}
}

/**
Expand All @@ -146,8 +149,9 @@ public void addType(final Type type) {
*/
public void addParametricType(final ParametricType parametricType) {
final TypeEnum baseType = parametricType.getBaseType();
Preconditions.checkArgument(!parametricTypes.containsKey(baseType),
"Parametric type already registered: %s", baseType);
if (parametricTypes.containsKey(baseType)) {
throw new IllegalArgumentException(String.format("Parametric type already registered: %s", baseType));
}
parametricTypes.putIfAbsent(baseType, parametricType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.base.Preconditions;
//import com.google.common.base.Preconditions;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import lombok.EqualsAndHashCode;
Expand Down Expand Up @@ -69,9 +69,10 @@ public TypeSignature(
) {
if (literalParameters != null) {
for (final Object literal : literalParameters) {
Preconditions.checkArgument(
literal instanceof String || literal instanceof Long,
"Unsupported literal type: %s", literal.getClass());
if (!(literal instanceof String || literal instanceof Long)) {
throw new IllegalArgumentException(
String.format("Unsupported literal type: %s", literal.getClass()));
}
}
this.literalParameters = ImmutableList.copyOf(literalParameters);
} else {
Expand Down Expand Up @@ -119,17 +120,28 @@ public static TypeSignature parseTypeSignature(final String signature) {
final char c = signature.charAt(i);
if (c == '<') {
if (bracketCount == 0) {
Preconditions.checkArgument(baseName == null, "Expected baseName to be null");
Preconditions.checkArgument(parameterStart == -1, "Expected parameter start to be -1");
if (baseName != null) {
throw new IllegalArgumentException("Expected baseName to be null");
}

if (parameterStart != -1) {
throw new IllegalArgumentException("Expected parameter start to be -1");
}

baseName = signature.substring(0, i);
parameterStart = i + 1;
}
bracketCount++;
} else if (c == '>') {
bracketCount--;
Preconditions.checkArgument(bracketCount >= 0, "Bad type signature: '%s'", signature);
if (bracketCount < 0) {
throw new IllegalArgumentException(String.format("Bad type signature: '%s'", signature));
}

if (bracketCount == 0) {
Preconditions.checkArgument(parameterStart >= 0, "Bad type signature: '%s'", signature);
if (parameterStart < 0) {
throw new IllegalArgumentException(String.format("Bad type signature: '%s'", signature));
}
parameters.add(parseTypeSignature(signature.substring(parameterStart, i)));
parameterStart = i + 1;
if (i == signature.length() - 1) {
Expand All @@ -138,31 +150,55 @@ public static TypeSignature parseTypeSignature(final String signature) {
}
} else if (c == ',') {
if (bracketCount == 1 && !inLiteralParameters) {
Preconditions.checkArgument(parameterStart >= 0, "Bad type signature: '%s'", signature);
if (parameterStart < 0) {
throw new IllegalArgumentException(String.format("Bad type signature: '%s'", signature));
}

parameters.add(parseTypeSignature(signature.substring(parameterStart, i)));
parameterStart = i + 1;
} else if (bracketCount == 0 && inLiteralParameters) {
Preconditions.checkArgument(parameterStart >= 0, "Bad type signature: '%s'", signature);
if (parameterStart < 0) {
throw new IllegalArgumentException(String.format("Bad type signature: '%s'", signature));
}

literalParameters.add(parseLiteral(signature.substring(parameterStart, i)));
parameterStart = i + 1;
}
} else if (c == '(') {
Preconditions.checkArgument(!inLiteralParameters, "Bad type signature: '%s'", signature);
if (inLiteralParameters) {
throw new IllegalArgumentException(String.format("Bad type signature: '%s'", signature));
}

inLiteralParameters = true;
if (bracketCount == 0) {
if (baseName == null) {
Preconditions.checkArgument(parameters.isEmpty(), "Expected no parameters");
Preconditions.checkArgument(parameterStart == -1, "Expected parameter start to be -1");
if (!parameters.isEmpty()) {
throw new IllegalArgumentException("Expected no parameters");
}

if (parameterStart != -1) {
throw new IllegalArgumentException("Expected parameter start to be -1");
}

baseName = signature.substring(0, i);
}
parameterStart = i + 1;
}
} else if (c == ')') {
Preconditions.checkArgument(inLiteralParameters, "Bad type signature: '%s'", signature);
if (!inLiteralParameters) {
throw new IllegalArgumentException(String.format("Bad type signature: '%s'", signature));
}

inLiteralParameters = false;
if (bracketCount == 0) {
Preconditions.checkArgument(i == signature.length() - 1, "Bad type signature: '%s'", signature);
Preconditions.checkArgument(parameterStart >= 0, "Bad type signature: '%s'", signature);
if (i != signature.length() - 1) {
throw new IllegalArgumentException(String.format("Bad type signature: '%s'", signature));
}

if (parameterStart < 0) {
throw new IllegalArgumentException(String.format("Bad type signature: '%s'", signature));
}

literalParameters.add(parseLiteral(signature.substring(parameterStart, i)));
return new TypeSignature(baseName, parameters, literalParameters);
}
Expand All @@ -173,7 +209,9 @@ public static TypeSignature parseTypeSignature(final String signature) {

private static Object parseLiteral(final String literal) {
if (literal.startsWith("'") || literal.endsWith("'")) {
Preconditions.checkArgument(literal.startsWith("'") && literal.endsWith("'"), "Bad literal: '%s'", literal);
if (!(literal.startsWith("'") && literal.endsWith("'"))) {
throw new IllegalArgumentException(String.format("Bad literal: '%s'", literal));
}
return literal.substring(1, literal.length() - 1);
} else {
return Long.parseLong(literal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class HiveConnectorFactory extends SpringConnectorFactory {
connectorContext.getConfiguration()
.getOrDefault(HiveConfigConstants.USE_EMBEDDED_METASTORE, "false")
);
final boolean useFastHiveService = useLocalMetastore && Boolean.parseBoolean(
final boolean useFastHiveService = Boolean.parseBoolean(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this anymore? I feel we should remove the embedded HMS entirely given it won't work anymore on SBN3.

connectorContext.getConfiguration()
.getOrDefault(HiveConfigConstants.USE_FASTHIVE_SERVICE, "false")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public HiveMetastoreClientFactory(@Nullable final HostAndPort socksProxy,
}

private static Socket createSocksSocket(final HostAndPort proxy) {
final SocketAddress address = InetSocketAddress.createUnresolved(proxy.getHostText(), proxy.getPort());
final SocketAddress address = InetSocketAddress.createUnresolved(proxy.getHost(), proxy.getPort());
return new Socket(new Proxy(Proxy.Type.SOCKS, address));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,9 @@ public void rename(final String databaseName,
final String newName) throws TException {
try (HiveMetastoreClient client = createMetastoreClient()) {
final Table table = client.get_table(databaseName, oldName);
client.drop_table(databaseName, oldName, false);
table.setDbName(newdatabadeName);
table.setTableName(newName);
client.create_table(table);
client.alter_table(databaseName, oldName, table);
}
}

Expand Down
Loading
Loading