diff --git a/rewrite-properties/src/main/java/org/openrewrite/properties/CreatePropertiesFile.java b/rewrite-properties/src/main/java/org/openrewrite/properties/CreatePropertiesFile.java index 0c8f899d1fb..1dbc298b93b 100644 --- a/rewrite-properties/src/main/java/org/openrewrite/properties/CreatePropertiesFile.java +++ b/rewrite-properties/src/main/java/org/openrewrite/properties/CreatePropertiesFile.java @@ -78,7 +78,7 @@ public TreeVisitor getScanner(AtomicBoolean shouldCreate) { @Override public Collection generate(AtomicBoolean shouldCreate, ExecutionContext ctx) { if (shouldCreate.get()) { - return PropertiesParser.builder().build().parse(!StringUtils.isBlank(fileContents) ? fileContents : "") + return PropertiesParser.builder().build().parse(fileContents == null ? "" : fileContents) .map(brandNewFile -> (SourceFile) brandNewFile.withSourcePath(Paths.get(relativeFileName))) .collect(Collectors.toList()); } diff --git a/rewrite-xml/src/main/java/org/openrewrite/xml/CreateXmlFile.java b/rewrite-xml/src/main/java/org/openrewrite/xml/CreateXmlFile.java index 0870e8f01dc..04a35bfa548 100644 --- a/rewrite-xml/src/main/java/org/openrewrite/xml/CreateXmlFile.java +++ b/rewrite-xml/src/main/java/org/openrewrite/xml/CreateXmlFile.java @@ -81,7 +81,7 @@ public TreeVisitor getScanner(AtomicBoolean shouldCreate) { @Override public Collection generate(AtomicBoolean shouldCreate, ExecutionContext ctx) { if (shouldCreate.get()) { - return XmlParser.builder().build().parse("") + return XmlParser.builder().build().parse(fileContents == null ? "" : fileContents) .map(brandNewFile -> (SourceFile) brandNewFile.withSourcePath(Paths.get(relativeFileName))) .collect(Collectors.toList()); } @@ -94,7 +94,7 @@ public TreeVisitor getVisitor(AtomicBoolean created) { return new XmlVisitor() { @Override public Xml visitDocument(Xml.Document document, ExecutionContext ctx) { - if ((created.get() || Boolean.TRUE.equals(overwriteExisting)) && path.equals(document.getSourcePath())) { + if (Boolean.TRUE.equals(overwriteExisting) && path.equals(document.getSourcePath())) { if (StringUtils.isBlank(fileContents)) { return document.withProlog(null).withRoot(null); }