Author: mona
Date: Fri Jan 25 17:45:20 2013
New Revision: 1438614

URL: http://svn.apache.org/viewvc?rev=1438614&view=rev
Log:
OOZIE-1186 Image load for Job DAG visualization should handle resources better 
(mona)

Modified:
    oozie/trunk/core/src/main/java/org/apache/oozie/util/GraphGenerator.java
    oozie/trunk/core/src/test/java/org/apache/oozie/util/TestGraphGenerator.java
    oozie/trunk/release-log.txt

Modified: 
oozie/trunk/core/src/main/java/org/apache/oozie/util/GraphGenerator.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/util/GraphGenerator.java?rev=1438614&r1=1438613&r2=1438614&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/util/GraphGenerator.java 
(original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/util/GraphGenerator.java 
Fri Jan 25 17:45:20 2013
@@ -84,7 +84,7 @@ public class GraphGenerator {
      * Overridden to thwart finalizer attack
      */
     @Override
-    public void finalize() {
+    public final void finalize() {
         // No-op; just to avoid finalizer attack
         // as the constructor is throwing an exception
     }
@@ -258,9 +258,24 @@ public class GraphGenerator {
 
             try {
                 ImageIO.write(img, "png", out);
-            } catch (IOException ioe) {
+            }
+            catch (IOException ioe) {
                 throw new SAXException(ioe);
             }
+            finally {
+                try {
+                    out.close(); //closing connection is imperative
+                                 //regardless of ImageIO.write throwing 
exception or not
+                                 //hence in finally block
+                }
+                catch (IOException e) {
+                    XLog.getLog(getClass()).trace("Exception while closing 
OutputStream");
+                }
+                out = null;
+                img.flush();
+                g.dispose();
+                vis.removeAll();
+            }
         }
 
         @Override

Modified: 
oozie/trunk/core/src/test/java/org/apache/oozie/util/TestGraphGenerator.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/util/TestGraphGenerator.java?rev=1438614&r1=1438613&r2=1438614&view=diff
==============================================================================
--- 
oozie/trunk/core/src/test/java/org/apache/oozie/util/TestGraphGenerator.java 
(original)
+++ 
oozie/trunk/core/src/test/java/org/apache/oozie/util/TestGraphGenerator.java 
Fri Jan 25 17:45:20 2013
@@ -31,13 +31,15 @@ public class TestGraphGenerator extends 
 
     public void testConstructor() {
         try {
-            GraphGenerator graphGenerator = new GraphGenerator(null, null);
-        } catch(IllegalArgumentException iae) {
+            new GraphGenerator(null, null);
+        }
+        catch (IllegalArgumentException iae) {
             Assert.assertTrue("Construction with illegal args failed as 
expected: " + iae.getMessage(), true);
         }
         try {
-            GraphGenerator graphGenerator1 = new 
GraphGenerator("<workflow></workflow>", null);
-        } catch(IllegalArgumentException iae) {
+            new GraphGenerator("<workflow></workflow>", null);
+        }
+        catch (IllegalArgumentException iae) {
             Assert.assertTrue("Construction with illegal args failed as 
expected: " + iae.getMessage(), true);
         }
         Assert.assertNotNull(new GraphGenerator("<workflow></workflow>", new 
JsonWorkflowJob()));
@@ -60,7 +62,8 @@ public class TestGraphGenerator extends 
         try {
             GraphGenerator g = new 
GraphGenerator(readFile("src/test/resources/graphWF.xml"), jsonWFJob);
             g.write(new FileOutputStream(new File(png1)));
-        } catch(Exception e) {
+        }
+        catch (Exception e) {
             Assert.fail("Write PNG failed for graphWF.xml: " + e.getMessage());
         }
 
@@ -68,14 +71,16 @@ public class TestGraphGenerator extends 
         try {
             // Check if a valid file was written
             Assert.assertNotNull(ImageIO.read(f1));
-        } catch(IOException io) {
+        }
+        catch (IOException io) {
             Assert.fail("Not a valid PNG: " + io.getMessage());
         }
 
         try {
             GraphGenerator g = new 
GraphGenerator(readFile("src/test/resources/graphWF.xml"), jsonWFJob, true);
             g.write(new FileOutputStream(new File(png2)));
-        } catch(Exception e) {
+        }
+        catch (Exception e) {
             Assert.fail("Write PNG failed for graphWF.xml: " + e.getMessage());
         }
 
@@ -83,7 +88,8 @@ public class TestGraphGenerator extends 
         try {
             // Check if a valid file was written
             Assert.assertNotNull(ImageIO.read(f2));
-        } catch(IOException io) {
+        }
+        catch (IOException io) {
             Assert.fail("Not a valid PNG: " + io.getMessage());
         }
 
@@ -94,7 +100,8 @@ public class TestGraphGenerator extends 
         try {
             GraphGenerator g = new 
GraphGenerator(readFile("src/test/resources/invalidGraphWF.xml"), jsonWFJob, 
true);
             g.write(new FileOutputStream(new 
File("src/test/resources/invalid.png")));
-        } catch(Exception e) {
+        }
+        catch (Exception e) {
             Assert.fail("Write PNG failed for invalidGraphWF.xml: " + 
e.getMessage());
         }
         new File("src/test/resources/invalid.png").delete();
@@ -102,7 +109,6 @@ public class TestGraphGenerator extends 
 
     private static String readFile(String path) throws IOException {
         File f = new File(path);
-        System.out.println(f.getAbsolutePath());
         FileInputStream stream = new FileInputStream(f);
         try {
             FileChannel fc = stream.getChannel();

Modified: oozie/trunk/release-log.txt
URL: 
http://svn.apache.org/viewvc/oozie/trunk/release-log.txt?rev=1438614&r1=1438613&r2=1438614&view=diff
==============================================================================
--- oozie/trunk/release-log.txt (original)
+++ oozie/trunk/release-log.txt Fri Jan 25 17:45:20 2013
@@ -1,5 +1,6 @@
 -- Oozie 3.4.0 release (trunk - unreleased)
 
+OOZIE-1186 Image load for Job DAG visualization should handle resources better 
(mona)
 OOZIE-1188 Typo in documentation for using login server example (rkanter)
 OOZIE-1160 Oozie web-console to display all job URLs spawned by Pig (mona)
 OOZIE-1177 HostnameFilter should only catch UnknownHostException, not 
Exception (rkanter)


Reply via email to