From d6d5f975b150d91b8bd47490b445e2328ef7eb79 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 7 Mar 2012 15:12:55 +0100 Subject: [PATCH] SONAR-1053 NPE in config backup --- .../sonar/server/configuration/Backup.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/Backup.java b/sonar-server/src/main/java/org/sonar/server/configuration/Backup.java index e48e222b12c..8620bfd44ca 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/Backup.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/Backup.java @@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory; import org.sonar.api.database.DatabaseSession; import org.sonar.jpa.entity.SchemaMigration; +import javax.annotation.Nullable; import java.io.IOException; import java.io.InputStream; import java.io.Writer; @@ -157,16 +158,18 @@ public class Backup { public HierarchicalStreamWriter createWriter(Writer out) { return new PrettyPrintWriter(out) { @Override - protected void writeText(QuickWriter writer, String text) { - writer.write("' so we will - * split all occurrences of this sequence into two CDATA first one would contain ']]' and second '>' - */ - text = StringUtils.replace(text, "]]>", "]]]]>"); - writer.write(text); - writer.write("]]>"); + protected void writeText(QuickWriter writer, @Nullable String text) { + if (text != null) { + writer.write("' so we will + * split all occurrences of this sequence into two CDATA first one would contain ']]' and second '>' + */ + text = StringUtils.replace(text, "]]>", "]]]]>"); + writer.write(text); + writer.write("]]>"); + } } }; } @@ -174,7 +177,7 @@ public class Backup { xStream.processAnnotations(SonarConfig.class); xStream.addDefaultImplementation(ArrayList.class, Collection.class); - xStream.registerConverter(new DateConverter(DATE_FORMAT, new String[] {})); + xStream.registerConverter(new DateConverter(DATE_FORMAT, new String[]{})); for (Backupable backupable : backupables) { backupable.configure(xStream); -- 2.39.5