This is an automated email from the git hooks/post-receive script. eugene-guest pushed a commit to annotated tag testng-6.9.5 in repository testng.
commit b1c39ae22168010e766a35496aaf9620784d6587 Author: Vladislav Rassokhin <[email protected]> Date: Sat Nov 2 01:50:04 2013 +0400 #Fixed testng-453 Encoding issue with XMLReporter +Nullable annotations +Possible NPE fix --- src/main/java/org/testng/internal/Utils.java | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/testng/internal/Utils.java b/src/main/java/org/testng/internal/Utils.java index faa58e5..52b6d5a 100644 --- a/src/main/java/org/testng/internal/Utils.java +++ b/src/main/java/org/testng/internal/Utils.java @@ -101,15 +101,18 @@ public final class Utils { return vResult.toArray(new String[vResult.size()]); } - public static void writeUtf8File(String outputDir, String fileName, XMLStringBuffer xsb, - String prefix) { + public static void writeUtf8File(String outputDir, String fileName, XMLStringBuffer xsb, String prefix) { try { - FileWriter fw = new FileWriter(new File(outputDir, fileName)); + final File file = new File(outputDir, fileName); + if (!file.exists()) { + file.createNewFile(); + } + final OutputStreamWriter w = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); if (prefix != null) { - fw.append(prefix); + w.append(prefix); } - xsb.toWriter(fw); - fw.close(); + xsb.toWriter(w); + w.close(); } catch(IOException ex) { ex.printStackTrace(); } @@ -123,7 +126,7 @@ public final class Utils { * @param fileName the filename * @param sb the file content */ - public static void writeUtf8File(String outputDir, String fileName, String sb) { + public static void writeUtf8File(@Nullable String outputDir, String fileName, String sb) { final String outDirPath= outputDir != null ? outputDir : ""; final File outDir= new File(outDirPath); writeFile(outDir, fileName, escapeUnicode(sb), "UTF-8", false /* don't append */); @@ -137,7 +140,7 @@ public final class Utils { * @param fileName the filename * @param sb the file content */ - public static void writeFile(String outputDir, String fileName, String sb) { + public static void writeFile(@Nullable String outputDir, String fileName, String sb) { final String outDirPath= outputDir != null ? outputDir : ""; final File outDir= new File(outDirPath); writeFile(outDir, fileName, sb, null, false /* don't append */); @@ -150,7 +153,7 @@ public final class Utils { * @param fileName file name * @param sb string to be appended to file */ - public static void appendToFile(String outputDir, String fileName, String sb) { + public static void appendToFile(@Nullable String outputDir, String fileName, String sb) { String outDirPath= outputDir != null ? outputDir : ""; File outDir= new File(outDirPath); writeFile(outDir, fileName, sb, null, true /* append */); @@ -164,8 +167,11 @@ public final class Utils { * @param fileName the filename * @param sb the file content */ - private static void writeFile(File outDir, String fileName, String sb, String encoding, boolean append) { + private static void writeFile(@Nullable File outDir, String fileName, String sb, @Nullable String encoding, boolean append) { try { + if (outDir == null) { + outDir = new File("").getAbsoluteFile(); + } if (!outDir.exists()) { outDir.mkdirs(); } @@ -188,7 +194,7 @@ public final class Utils { } } - private static void writeFile(File outputFile, String sb, String encoding, boolean append) { + private static void writeFile(File outputFile, String sb, @Nullable String encoding, boolean append) { BufferedWriter fw = null; try { if (!outputFile.exists()) { -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/testng.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

