Skip to content

Commit

Permalink
[Apps Plugin] Allow bad enum constants (take 2) (#546)
Browse files Browse the repository at this point in the history
Improving on the previous commit, this adds a set of expected
problematic enum classes and only continues processing when an enum
is unable to load if the enum is in the list.
  • Loading branch information
onobc authored Jun 3, 2024
1 parent e7ece24 commit 5ef97cc
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.jar.JarOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
Expand Down Expand Up @@ -108,6 +110,11 @@ public class MetadataAggregationMojo extends AbstractMojo {

static final String SPRING_CLOUD_DATAFLOW_OPTION_GROUPS_PROPERTIES = "dataflow-configuration-option-groups.properties";

private static final Set<String> KNOWN_PROBLEMATIC_ENUMS = new HashSet<>();
static {
KNOWN_PROBLEMATIC_ENUMS.add("org.springframework.boot.autoconfigure.data.jdbc.JdbcDatabaseDialect");
}

@Parameter(defaultValue = "${project}")
private MavenProject mavenProject;

Expand Down Expand Up @@ -527,8 +534,13 @@ void addEnumHints(ConfigurationMetadata configurationMetadata, ClassLoader class
enumConstants = clazz.getEnumConstants();
}
catch (NoClassDefFoundError ex) {
getLog().error("Failed to resolve enum constants for property = " + property + " and class = " + clazz, ex);
continue;
String enumClass = clazz.getName();
if (KNOWN_PROBLEMATIC_ENUMS.contains(enumClass)) {
getLog().info("[EXPECTED] Failed to resolve enum constants for property = " + property + " and class = " + clazz);
continue;
}
getLog().error("[UNEXPECTED] Failed to resolve enum constants for property = " + property + " and class = " + clazz, ex);
throw ex;
}
for (Object enumConstant : enumConstants) {
valueHints.add(new ValueHint(enumConstant, null));
Expand Down

0 comments on commit 5ef97cc

Please sign in to comment.