diff --git a/logstash-core/build.gradle b/logstash-core/build.gradle index 5332c275c94..0ab86114213 100644 --- a/logstash-core/build.gradle +++ b/logstash-core/build.gradle @@ -183,12 +183,6 @@ dependencies { api files(customJRubyDir + "/maven/jruby-complete/target/jruby-complete-${customJRubyVersion}.jar") } implementation group: 'com.google.guava', name: 'guava', version: '24.1.1-jre' - // WARNING: DO NOT UPGRADE "google-java-format" - // later versions require GPL licensed code in javac-shaded that is - // Apache2 incompatible - implementation('com.google.googlejavaformat:google-java-format:1.1') { - exclude group: 'com.google.guava', module: 'guava' - } implementation 'org.javassist:javassist:3.26.0-GA' testImplementation "org.apache.logging.log4j:log4j-core:${log4jVersion}:tests" testImplementation 'org.hamcrest:hamcrest:2.2' diff --git a/logstash-core/src/main/java/org/logstash/config/ir/compiler/ComputeStepSyntaxElement.java b/logstash-core/src/main/java/org/logstash/config/ir/compiler/ComputeStepSyntaxElement.java index 42541f2a56a..9064608d097 100644 --- a/logstash-core/src/main/java/org/logstash/config/ir/compiler/ComputeStepSyntaxElement.java +++ b/logstash-core/src/main/java/org/logstash/config/ir/compiler/ComputeStepSyntaxElement.java @@ -21,8 +21,6 @@ package org.logstash.config.ir.compiler; import com.google.common.annotations.VisibleForTesting; -import com.google.googlejavaformat.java.Formatter; -import com.google.googlejavaformat.java.FormatterException; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.nio.charset.StandardCharsets; @@ -63,12 +61,6 @@ public final class ComputeStepSyntaxElement { private static final AtomicLong DATASET_CLASS_INDEX = new AtomicLong(0); - /** - * Pattern to remove redundant {@code ;} from formatted code since {@link Formatter} does not - * remove those. - */ - private static final Pattern REDUNDANT_SEMICOLON = Pattern.compile("\n[ ]*;\n"); - private static final String CLASS_NAME_PLACEHOLDER = "CLASS_NAME_PLACEHOLDER"; private static final Pattern CLASS_NAME_PLACEHOLDER_REGEX = Pattern.compile(CLASS_NAME_PLACEHOLDER); @@ -170,24 +162,17 @@ public boolean equals(final Object other) { } private String generateCode(final String name) { - try { - return REDUNDANT_SEMICOLON.matcher(new Formatter().formatSource( - String.format( - "package org.logstash.generated;\npublic final class %s extends org.logstash.config.ir.compiler.BaseDataset implements %s { %s }", - name, - type.getName(), - SyntaxFactory.join( - fields.inlineAssigned().generateCode(), fieldsAndCtor(name), - combine( - StreamSupport.stream(methods.spliterator(), false) - .toArray(SyntaxElement[]::new) - ) + return String.format( + "package org.logstash.generated;\npublic final class %s extends org.logstash.config.ir.compiler.BaseDataset implements %s { %s }", + name, + type.getName(), + SyntaxFactory.join( + fields.inlineAssigned().generateCode(), fieldsAndCtor(name), + combine( + StreamSupport.stream(methods.spliterator(), false) + .toArray(SyntaxElement[]::new) ) - ) - )).replaceAll("\n"); - } catch (final FormatterException ex) { - throw new IllegalStateException(ex); - } + )); } private static Path debugDir() {