From bbeb429a5938083beab778113d320bb49929d983 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Tue, 7 Oct 2014 11:56:18 +0000
Subject: [PATCH] Graphs: Catch an error caused by missing fonts

---
 .../net/i2p/router/web/StatSummarizer.java    | 32 +++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/apps/routerconsole/java/src/net/i2p/router/web/StatSummarizer.java b/apps/routerconsole/java/src/net/i2p/router/web/StatSummarizer.java
index 7fcad4071c..853bcbe81a 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/StatSummarizer.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/StatSummarizer.java
@@ -192,8 +192,22 @@ public class StatSummarizer implements Runnable {
             try {
                 _sem.acquire();
             } catch (InterruptedException ie) {}
-            return locked_renderPng(rate, out, width, height, hideLegend, hideGrid, hideTitle, showEvents,
+            try {
+                return locked_renderPng(rate, out, width, height, hideLegend, hideGrid, hideTitle, showEvents,
                                     periodCount, end, showCredit);
+            } catch (NoClassDefFoundError ncdfe) {
+                //  java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager
+                //  at java.lang.Class.forName0(Native Method)
+                //  at java.lang.Class.forName(Class.java:270)
+                //  at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:82)
+                _isDisabled = true;
+                _isRunning = false;
+                String s = "Error rendering - disabling graph generation. Install ttf-dejavu font package?";
+                _log.logAlways(Log.WARN, s);
+                IOException ioe = new IOException(s);
+                ioe.initCause(ncdfe);
+                throw ioe;
+            }
         } finally {
             _sem.release();
         }
@@ -268,8 +282,22 @@ public class StatSummarizer implements Runnable {
             try {
                 _sem.acquire();
             } catch (InterruptedException ie) {}
-            return locked_renderRatePng(out, width, height, hideLegend, hideGrid, hideTitle, showEvents,
+            try {
+                return locked_renderRatePng(out, width, height, hideLegend, hideGrid, hideTitle, showEvents,
                                         periodCount, end, showCredit);
+            } catch (NoClassDefFoundError ncdfe) {
+                //  java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager
+                //  at java.lang.Class.forName0(Native Method)
+                //  at java.lang.Class.forName(Class.java:270)
+                //  at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:82)
+                _isDisabled = true;
+                _isRunning = false;
+                String s = "Error rendering - disabling graph generation. Install ttf-dejavu font package?";
+                _log.logAlways(Log.WARN, s);
+                IOException ioe = new IOException(s);
+                ioe.initCause(ncdfe);
+                throw ioe;
+            }
         } finally {
             _sem.release();
         }
-- 
GitLab