/hg/gfx-test: Fixed some issues found by FindBugs.
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Mon Feb 20 07:26:05 PST 2012
changeset ea826a03b3bd in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=ea826a03b3bd
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Feb 20 16:28:10 2012 +0100
Fixed some issues found by FindBugs.
diffstat:
ChangeLog | 8 +
src/org/gfxtest/ImageDiffer/Main.java | 8 +-
src/org/gfxtest/ImageDiffer/ResultWriters/HtmlStructureWriter.java | 57 ++++++++-
src/org/gfxtest/reporter/Reporter.java | 17 ++-
4 files changed, 77 insertions(+), 13 deletions(-)
diffs (175 lines):
diff -r bdd419eb8d7d -r ea826a03b3bd ChangeLog
--- a/ChangeLog Fri Feb 17 11:20:40 2012 +0100
+++ b/ChangeLog Mon Feb 20 16:28:10 2012 +0100
@@ -1,4 +1,12 @@
+2012-02-20 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/ImageDiffer/Main.java:
+ * src/org/gfxtest/ImageDiffer/ResultWriters/HtmlStructureWriter.java:
+ * src/org/gfxtest/reporter/Reporter.java:
+ Fixed some issues found by FindBugs.
+
2012-02-17 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/testsuites/BitBltBasicTests.java:
* src/org/gfxtest/testsuites/BitBltMirrorImage.java:
* src/org/gfxtest/testsuites/BitBltScaleImage.java:
diff -r bdd419eb8d7d -r ea826a03b3bd src/org/gfxtest/ImageDiffer/Main.java
--- a/src/org/gfxtest/ImageDiffer/Main.java Fri Feb 17 11:20:40 2012 +0100
+++ b/src/org/gfxtest/ImageDiffer/Main.java Mon Feb 20 16:28:10 2012 +0100
@@ -62,7 +62,7 @@
private int sameImageCounter = 0;
private static Log log = new Log(Main.class.getName(), true);
- public void Run(String[] args) throws Exception
+ public void run(String[] args) throws Exception
{
Configuration configuration = new Configuration(args);
List<ResultWriter> resultWriters = new ArrayList<ResultWriter>();
@@ -212,7 +212,9 @@
String dirName = imageFileName.substring(0, imageFileName.lastIndexOf('.'));
File newDir = new File(configuration.getOutputDirectory(), dirName);
log.logProcess("creating directory %s", newDir.getAbsolutePath());
- newDir.mkdir();
+ if (!newDir.mkdir()) {
+ log.logError("error creating directory %s", newDir.getAbsolutePath());
+ }
log.logProcess("writing source and diff images to directory %s", dirName);
ImageUtils.writeImage(sourceImages[0], newDir, "source1.png");
ImageUtils.writeImage(sourceImages[1], newDir, "source2.png");
@@ -250,7 +252,7 @@
try
{
log.logBegin(String.format("started at %s", new Date().toString()));
- new Main().Run(args);
+ new Main().run(args);
}
catch (Exception e)
{
diff -r bdd419eb8d7d -r ea826a03b3bd src/org/gfxtest/ImageDiffer/ResultWriters/HtmlStructureWriter.java
--- a/src/org/gfxtest/ImageDiffer/ResultWriters/HtmlStructureWriter.java Fri Feb 17 11:20:40 2012 +0100
+++ b/src/org/gfxtest/ImageDiffer/ResultWriters/HtmlStructureWriter.java Mon Feb 20 16:28:10 2012 +0100
@@ -47,6 +47,7 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -72,7 +73,10 @@
{
File newDir = new File(configuration.getOutputDirectory(), dirName);
log.logProcess("creating directory %s", newDir.getAbsolutePath());
- newDir.mkdir();
+ if (!newDir.mkdir())
+ {
+ log.logError("error creating directory %s", newDir.getAbsolutePath());
+ }
if (!comparisonResult.isEqualsImages())
{
log.logProcess("writing source and diff images to directory %s", dirName);
@@ -91,15 +95,29 @@
private static void createHtmlFile(File newDir, ComparisonResult cr) throws IOException
{
String templateName = cr.isEqualsImages() ? "template_same_images.html" : "template_different_images.html";
- BufferedWriter writer = new BufferedWriter(new FileWriter(new File(newDir, "result.html")));
- BufferedReader template = new BufferedReader(new FileReader(new File(TEMPLATE_DIR, templateName)));
- String line;
- while ((line = template.readLine()) != null)
+ BufferedWriter writer = null;
+ BufferedReader template = null;
+ try
{
- writer.write(replacePlaceholders(cr, newDir, line));
+ writer = new BufferedWriter(new FileWriter(new File(newDir, "result.html")));
+ template = new BufferedReader(new FileReader(new File(TEMPLATE_DIR, templateName)));
+ String line;
+ while ((line = template.readLine()) != null)
+ {
+ writer.write(replacePlaceholders(cr, newDir, line));
+ }
}
- template.close();
- writer.close();
+ finally
+ {
+ if (template != null)
+ {
+ template.close();
+ }
+ if (writer != null)
+ {
+ writer.close();
+ }
+ }
}
private static String replacePlaceholders(ComparisonResult cr, File newDir, String line)
@@ -125,8 +143,29 @@
method = cr.getClass().getDeclaredMethod("get" + group, (Class<?>[]) null);
return "" + method.invoke(cr, (Object[]) null);
}
- catch (Exception e)
+ catch (IllegalAccessException e)
{
+ // print ST in case of exception
+ e.printStackTrace();
+ }
+ catch (SecurityException e)
+ {
+ // print ST in case of exception
+ e.printStackTrace();
+ }
+ catch (NoSuchMethodException e)
+ {
+ // print ST in case of exception
+ e.printStackTrace();
+ }
+ catch (IllegalArgumentException e)
+ {
+ // print ST in case of exception
+ e.printStackTrace();
+ }
+ catch (InvocationTargetException e)
+ {
+ // print ST in case of exception
e.printStackTrace();
}
return group;
diff -r bdd419eb8d7d -r ea826a03b3bd src/org/gfxtest/reporter/Reporter.java
--- a/src/org/gfxtest/reporter/Reporter.java Fri Feb 17 11:20:40 2012 +0100
+++ b/src/org/gfxtest/reporter/Reporter.java Mon Feb 20 16:28:10 2012 +0100
@@ -43,7 +43,11 @@
import java.io.*;
import java.util.*;
import javax.xml.parsers.*;
+
+
+
import org.w3c.dom.*;
+import org.xml.sax.SAXException;
import org.gfxtest.common.ConfigurationException;
import org.gfxtest.framework.Log;
@@ -267,8 +271,19 @@
}
}
}
- catch (Exception e)
+ catch (ParserConfigurationException e)
{
+ // print ST in case of exception
+ e.printStackTrace();
+ }
+ catch (SAXException e)
+ {
+ // print ST in case of exception
+ e.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ // print ST in case of exception
e.printStackTrace();
}
finally
More information about the distro-pkg-dev
mailing list