Skip to content

Commit

Permalink
Ignore SpotBugs warning in ConfigMetadataHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
arouel committed Oct 4, 2024
1 parent c0bf510 commit 1e4ed11
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -50,7 +52,7 @@
/*
* This class is separated so javac correctly reports possible errors.
*/
class ConfigMetadataHandler {
class ConfigMetadataHandler {
/*
* Configuration metadata file location.
*/
Expand Down Expand Up @@ -94,11 +96,8 @@ boolean process(RoundEnvironment roundEnv) {
try {
return doProcess(roundEnv);
} catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
messager.printMessage(Diagnostic.Kind.ERROR, "Failed to process config metadata annotation processor. "
+ sw);
+ stackTraceAsString(e));
return false;
}
}
Expand Down Expand Up @@ -213,7 +212,21 @@ private void storeMetadata() {
}
}

private String toMessage(Exception e) {
return e.getClass().getName() + ": " + e.getMessage();
@Retention(RetentionPolicy.CLASS)
private @interface SuppressFBWarnings {

String[] value() default {};

String justification() default "";
}

@SuppressFBWarnings(
value = "INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE",
justification = "During compile time this isn't a problem.")
private static String stackTraceAsString(Throwable e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
return sw.toString();
}
}
2 changes: 1 addition & 1 deletion config/metadata/processor/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@

provides javax.annotation.processing.Processor with io.helidon.config.metadata.processor.ConfigMetadataProcessor;

}
}

0 comments on commit 1e4ed11

Please sign in to comment.