Skip to content

Commit

Permalink
[apache#3649] feat(client): remove log4j impl from client-java-runtime (
Browse files Browse the repository at this point in the history
  • Loading branch information
FANNG1 committed May 31, 2024
1 parent 9ae0d17 commit d775bbd
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 47 deletions.
9 changes: 8 additions & 1 deletion clients/client-java-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ plugins {
alias(libs.plugins.shadow)
}

configurations.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.apache.logging.log4j") {
throw GradleException("Forbidden dependency 'org.apache.logging.log4j' found!")
}
}
}

dependencies {
implementation(project(":clients:client-java"))
}
Expand All @@ -24,7 +32,6 @@ tasks.withType<ShadowJar>(ShadowJar::class.java) {
relocate("com.fasterxml", "com.datastrato.gravitino.shaded.com.fasterxml")
relocate("org.apache.httpcomponents", "com.datastrato.gravitino.shaded.org.apache.httpcomponents")
relocate("org.apache.commons", "com.datastrato.gravitino.shaded.org.apache.commons")
relocate("org.apache.logging", "com.datastrato.gravitino.shaded.org.apache.logging")
relocate("org.antlr", "com.datastrato.gravitino.shaded.org.antlr")
}

Expand Down
1 change: 0 additions & 1 deletion clients/client-java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies {
implementation(libs.jackson.datatype.jdk8)
implementation(libs.jackson.datatype.jsr310)
implementation(libs.guava)
implementation(libs.bundles.log4j)
implementation(libs.httpclient5)
implementation(libs.commons.lang3)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* BaseSchemaCatalog is the base abstract class for all the catalog with schema. It provides the
* common methods for managing schemas in a catalog. With {@link BaseSchemaCatalog}, users can list,
* create, load, alter and drop a schema with specified identifier.
*/
abstract class BaseSchemaCatalog extends CatalogDTO implements SupportsSchemas {
private static final Logger LOG = LoggerFactory.getLogger(BaseSchemaCatalog.class);

/** The REST client to send the requests. */
protected final RESTClient restClient;
Expand Down Expand Up @@ -194,7 +191,6 @@ public boolean dropSchema(NameIdentifier ident, boolean cascade) throws NonEmpty
} catch (NonEmptySchemaException e) {
throw e;
} catch (Exception e) {
LOG.warn("Failed to drop schema {}", ident, e);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import com.google.common.base.Joiner;
import java.util.List;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Utility class providing error handling for REST requests and specific to Metalake errors.
Expand All @@ -46,8 +44,6 @@
*/
public class ErrorHandlers {

private static final Logger LOG = LoggerFactory.getLogger(ErrorHandlers.class);

/**
* Creates an error handler specific to Metalake operations.
*
Expand Down Expand Up @@ -396,11 +392,12 @@ public ErrorResponse parseResponse(int code, String json, ObjectMapper mapper) {
try {
OAuth2ErrorResponse response = mapper.readValue(json, OAuth2ErrorResponse.class);
return ErrorResponse.oauthError(code, response.getType(), response.getMessage());
} catch (Exception x) {
LOG.warn("Unable to parse error response", x);
} catch (Exception e) {
String errorMsg =
String.format(
"Error code: %d, error message: %s, json string: %s", code, e.getMessage(), json);
return ErrorResponse.unknownError(errorMsg);
}
String errorMsg = String.format("Error code: %d, message: %s", code, json);
return ErrorResponse.unknownError(errorMsg);
}

/**
Expand Down Expand Up @@ -651,11 +648,11 @@ public ErrorResponse parseResponse(int code, String json, ObjectMapper mapper) {
try {
return mapper.readValue(json, ErrorResponse.class);
} catch (Exception e) {
LOG.warn("Failed to parse response: {}", json, e);
String errorMsg =
String.format(
"Error code: %d, error message: %s, json string: %s", code, e.getMessage(), json);
return ErrorResponse.unknownError(errorMsg);
}

String errorMsg = String.format("Error code: %d, message: %s", code, json);
return ErrorResponse.unknownError(errorMsg);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Gravitino Client for the administrator to interact with the Gravitino API, allowing the client to
Expand All @@ -54,7 +52,6 @@
*/
public class GravitinoAdminClient extends GravitinoClientBase implements SupportsMetalakes {

private static final Logger LOG = LoggerFactory.getLogger(GravitinoAdminClient.class);
private static final String API_METALAKES_USERS_PATH = "api/metalakes/%s/users/%s";
private static final String API_METALAKES_GROUPS_PATH = "api/metalakes/%s/groups/%s";
private static final String API_METALAKES_ROLES_PATH = "api/metalakes/%s/roles/%s";
Expand Down Expand Up @@ -184,7 +181,6 @@ public boolean dropMetalake(NameIdentifier ident) {
return resp.dropped();

} catch (Exception e) {
LOG.warn("Failed to drop metadata {}", ident, e);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Base class for Gravitino Java client;
Expand All @@ -30,7 +28,6 @@
*/
public abstract class GravitinoClientBase implements Closeable {

private static final Logger LOG = LoggerFactory.getLogger(GravitinoClientBase.class);
/** The REST client to communicate with the REST server */
protected final RESTClient restClient;
/** The REST API path for listing metalakes */
Expand Down Expand Up @@ -156,7 +153,6 @@ public void close() {
restClient.close();
} catch (Exception e) {
// Swallow the exception
LOG.warn("Failed to close the HTTP REST client", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Gravitino Metalake is the top-level metadata repository for users. It contains a list of catalogs
Expand All @@ -39,8 +37,6 @@
*/
public class GravitinoMetalake extends MetalakeDTO implements SupportsCatalogs {

private static final Logger LOG = LoggerFactory.getLogger(GravitinoMetalake.class);

private static final String API_METALAKES_CATALOGS_PATH = "api/metalakes/%s/catalogs/%s";

private final RESTClient restClient;
Expand Down Expand Up @@ -217,7 +213,6 @@ public boolean dropCatalog(NameIdentifier ident) {
return resp.dropped();

} catch (Exception e) {
LOG.warn("Failed to drop catalog {}", ident, e);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.net.URIBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* An HttpClient for usage with the REST catalog.
Expand All @@ -69,8 +67,6 @@
*/
public class HTTPClient implements RESTClient {

private static final Logger LOG = LoggerFactory.getLogger(HTTPClient.class);

private static final String VERSION_HEADER = "application/vnd.gravitino.v1+json";

private final String uri;
Expand Down Expand Up @@ -205,9 +201,6 @@ private void throwFailure(
errorResponse =
((ErrorHandler) errorHandler).parseResponse(response.getCode(), responseBody, mapper);
} else {
LOG.warn(
"Unknown error handler {}, response body won't be parsed",
errorHandler.getClass().getName());
errorResponse =
ErrorResponse.unknownError(
String.format(
Expand All @@ -222,7 +215,6 @@ private void throwFailure(
// In such cases, we handle the situation by building an error response for the user.
// Examples of such scenarios include network timeouts or load balancers returning default
// 5xx responses.
LOG.error("Failed to parse an error response. Will create one instead.", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Relational catalog is a catalog implementation that supports relational database like metadata
Expand All @@ -48,8 +46,6 @@
*/
public class RelationalCatalog extends BaseSchemaCatalog implements TableCatalog {

private static final Logger LOG = LoggerFactory.getLogger(RelationalCatalog.class);

RelationalCatalog(
String name,
Type type,
Expand Down Expand Up @@ -216,7 +212,6 @@ public boolean dropTable(NameIdentifier ident) {
return resp.dropped();

} catch (Exception e) {
LOG.warn("Failed to drop table {}", ident, e);
return false;
}
}
Expand Down Expand Up @@ -245,11 +240,9 @@ public boolean purgeTable(NameIdentifier ident) throws UnsupportedOperationExcep
ErrorHandlers.tableErrorHandler());
resp.validate();
return resp.dropped();

} catch (UnsupportedOperationException e) {
throw e;
} catch (Exception e) {
LOG.warn("Failed to purge table {}", ident, e);
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions clients/filesystem-hadoop3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies {
implementation(project(":clients:client-java-runtime", configuration = "shadow"))
implementation(libs.caffeine)

testImplementation(project(":core"))
testImplementation(project(":server-common"))
testImplementation(libs.awaitility)
testImplementation(libs.bundles.jwt)
Expand Down
1 change: 0 additions & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ plugins {
dependencies {
implementation(project(":api"))

implementation(libs.bundles.log4j)
implementation(libs.commons.collections4)
implementation(libs.commons.lang3)
implementation(libs.guava)
Expand Down

0 comments on commit d775bbd

Please sign in to comment.