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

Dev console config editor - fix NPE if application.properties missing #14256

Closed
Closed
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 @@ -15,7 +15,6 @@

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.ConfigDescriptionBuildItem;
Expand All @@ -28,8 +27,6 @@

public class ConfigEditorProcessor {

private static final Logger log = Logger.getLogger(ConfigEditorProcessor.class);

@BuildStep
DevConsoleTemplateInfoBuildItem config(List<ConfigDescriptionBuildItem> config) throws Exception {
List<CurrentConfig> configs = new ArrayList<>();
Expand Down Expand Up @@ -86,6 +83,14 @@ protected void handlePost(RoutingContext event, MultiMap form) throws Exception
appProperties.load(in);
present = appProperties.containsKey(key);
}
} else {
// If there is no application.properties file then create a new one in the first module
List<Path> resourcesDir = DevConsoleManager.getHotReplacementContext().getResourcesDir();
if (resourcesDir.isEmpty()) {
throw new IllegalStateException(
"Unable to create application.properties - no resource directory found");
}
appProps = Files.createFile(resourcesDir.get(0).resolve("application.properties"));
}
if (!present) {
try (OutputStream out = Files.newOutputStream(appProps, StandardOpenOption.APPEND)) {
Expand Down