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

Migrate deprecated APIs and cleanups #161

Open
wants to merge 3 commits into
base: main
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

public class AbstractV1ConfigurationParserTest extends AbstractConfigurationMapperTest {

static ConfigurationNode EXAMPLE_V1_CONFIGURATION = newNodeBuilder()
static final ConfigurationNode EXAMPLE_V1_CONFIGURATION = newNodeBuilder()
.setPluginName("Configuration")
.addChild(newNodeBuilder()
.setPluginName("Properties")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
Expand Down Expand Up @@ -102,7 +101,7 @@ public class LocationMojo extends AbstractMojo {
private int staleMillis;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
public void execute() throws MojoExecutionException {
if ("pom".equals(project.getPackaging())) {
getLog().info("Skipping project with packaging \"pom\".");
return;
Expand Down Expand Up @@ -192,7 +191,7 @@ private WrappedIOException(IOException cause) {
}
}

private boolean validateLog4jVersion() throws MojoExecutionException {
private boolean validateLog4jVersion() {
Optional<Artifact> artifact = project.getArtifacts().stream()
.filter(a -> LOG4J_GROUP_ID.equals(a.getGroupId()) && LOG4J_API_ARTIFACT_ID.equals(a.getArtifactId()))
.findAny();
Expand All @@ -210,7 +209,7 @@ private boolean validateLog4jVersion() throws MojoExecutionException {
return false;
}
// Transitive dependency
if (!project.getDependencyArtifacts().contains(log4jApi)) {
if (!project.getArtifacts().contains(log4jApi)) {
getLog().warn("Log4j2 API should not be a transitive dependency.");
}
} catch (OverConstrainedVersionException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.logging.log4j.maven.plugins.shade.transformer;

import static org.apache.commons.io.output.ClosedOutputStream.CLOSED_OUTPUT_STREAM;
import static org.apache.commons.io.output.ClosedOutputStream.INSTANCE;

import java.io.IOException;
import java.io.OutputStream;
Expand All @@ -37,6 +37,6 @@ final class CloseShieldOutputStream extends ProxyOutputStream {
@Override
public void close() throws IOException {
out.flush();
out = CLOSED_OUTPUT_STREAM;
out = INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void processResource(
*/
@Override
public boolean hasTransformedResource() {
return tempFiles.size() > 0;
return !tempFiles.isEmpty();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public int getIndex() {
*/
private static class LocationCacheContents {
private final List<StackTraceElement> locations = new CopyOnWriteArrayList<>();
private Set<SupplierLambdaType> lambdas = EnumSet.noneOf(SupplierLambdaType.class);
private final Set<SupplierLambdaType> lambdas = EnumSet.noneOf(SupplierLambdaType.class);

public int addLocation(
final String internalClassName, final String methodName, final String fileName, final int lineNumber) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
public class LocationMethodVisitor extends GeneratorAdapter {

// Programmatically define LAMBDA_METAFACTORY_HANDLE
private static Type SUPPLIER_OF_OBJECT_TYPE = Type.getMethodType(OBJECT_TYPE);
private static Type SUPPLIER_OF_MESSAGE_TYPE = Type.getMethodType(MESSAGE_TYPE);
private static final Type SUPPLIER_OF_OBJECT_TYPE = Type.getMethodType(OBJECT_TYPE);
private static final Type SUPPLIER_OF_MESSAGE_TYPE = Type.getMethodType(MESSAGE_TYPE);
private static final Type LAMBDA_METAFACTORY_TYPE = Type.getType(LambdaMetafactory.class);
private static final Type METHOD_HANDLE_TYPE = Type.getType(MethodHandle.class);
private static final Type METHOD_TYPE_TYPE = Type.getType(MethodType.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ private void handleTraceEntry(LocationMethodVisitor mv, String descriptor) {
if (types.length == 1) {
mv.push((String) null);
}
for (int i = 0; i < vars.length; i++) {
mv.loadLocal(vars[i]);
for (int var : vars) {
mv.loadLocal(var);
}
final boolean usesSuppliers = types[types.length - 1].equals(SUPPLIER_ARRAY_TYPE);
mv.invokeSupplierLambda(
Expand Down
Loading