Skip to content

Commit a02cd76

Browse files
gnodetclaude
andcommitted
CAMEL-21208: Minor cleanup from review
- Remove unnecessary bare block in Run.generateOpenApi (leftover from try-with-resources) - Deduplicate model building in Export.copyDockerFiles Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e3c9208 commit a02cd76

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

  • dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands

dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,21 +305,18 @@ protected void copyDockerFiles(String buildDir) throws Exception {
305305
Files.createDirectories(docker);
306306
String[] ids = gav.split(":");
307307

308+
Map<String, Object> model = new HashMap<>();
309+
model.put("ArtifactId", ids[1]);
310+
model.put("Version", ids[2]);
311+
model.put("AppJar", ids[1] + "-" + ids[2] + ".jar");
312+
308313
String ftlName = "Dockerfile" + javaVersion + ".ftl";
309314
String context;
310315
try {
311-
Map<String, Object> model = new HashMap<>();
312-
model.put("ArtifactId", ids[1]);
313-
model.put("Version", ids[2]);
314-
model.put("AppJar", ids[1] + "-" + ids[2] + ".jar");
315316
context = TemplateHelper.processTemplate(ftlName, model);
316317
} catch (IOException e) {
317318
// fallback to JDK 21 template
318319
printer().printf("No Dockerfile template for Java %s, falling back to Java 21 template%n", javaVersion);
319-
Map<String, Object> model = new HashMap<>();
320-
model.put("ArtifactId", ids[1]);
321-
model.put("Version", ids[2]);
322-
model.put("AppJar", ids[1] + "-" + ids[2] + ".jar");
323320
context = TemplateHelper.processTemplate("Dockerfile21.ftl", model);
324321
}
325322
Files.writeString(docker.resolve("Dockerfile"), context);

dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,15 +1893,13 @@ private void generateOpenApi() throws Exception {
18931893
throw new FileNotFoundException("Cannot find file: " + filePath);
18941894
}
18951895

1896-
{
1897-
Map<String, Object> model = new HashMap<>();
1898-
model.put("Spec", filePath.toString());
1899-
String content = TemplateHelper.processTemplate("rest-dsl.yaml.ftl", model);
1900-
Files.writeString(Paths.get(OPENAPI_GENERATED_FILE), content);
1896+
Map<String, Object> model = new HashMap<>();
1897+
model.put("Spec", filePath.toString());
1898+
String content = TemplateHelper.processTemplate("rest-dsl.yaml.ftl", model);
1899+
Files.writeString(Paths.get(OPENAPI_GENERATED_FILE), content);
19011900

1902-
// we need to include the spec on the classpath
1903-
files.add(openapi);
1904-
}
1901+
// we need to include the spec on the classpath
1902+
files.add(openapi);
19051903
}
19061904

19071905
private boolean knownFile(String file) throws Exception {

0 commit comments

Comments
 (0)