From 09d98be8d7ead370958ef9964e02e1ba5b5b4869 Mon Sep 17 00:00:00 2001 From: samskivert Date: Tue, 9 Feb 2010 20:13:01 +0000 Subject: [PATCH] Avoid NPE. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2712 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../samskivert/velocity/ServletContextResourceManager.java | 3 ++- src/java/com/samskivert/velocity/SiteResourceManager.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/java/com/samskivert/velocity/ServletContextResourceManager.java b/src/java/com/samskivert/velocity/ServletContextResourceManager.java index a2bad8af..5fa321f7 100644 --- a/src/java/com/samskivert/velocity/ServletContextResourceManager.java +++ b/src/java/com/samskivert/velocity/ServletContextResourceManager.java @@ -37,7 +37,6 @@ public class ServletContextResourceManager extends ResourceManagerImpl throws Exception { super.initialize(rsvc); - rsvc.getLog().info("SCRM initializing."); // the web framework was kind enough to slip this into the runtime when it started up Application app = (Application)rsvc.getApplicationAttribute(Application.VELOCITY_ATTR_KEY); @@ -45,7 +44,9 @@ public class ServletContextResourceManager extends ResourceManagerImpl rsvc.getLog().warn("SCRM: No application was initialized. A user of the " + "servlet context resource manager must ensure that " + "an application is instantiated and initialized."); + return; } + rsvc.getLog().info("SCRM initializing."); // create our resource loader _contextLoader = new ServletContextResourceLoader(app.getServletContext()); diff --git a/src/java/com/samskivert/velocity/SiteResourceManager.java b/src/java/com/samskivert/velocity/SiteResourceManager.java index d5d1970e..47716375 100644 --- a/src/java/com/samskivert/velocity/SiteResourceManager.java +++ b/src/java/com/samskivert/velocity/SiteResourceManager.java @@ -46,16 +46,16 @@ public class SiteResourceManager extends ResourceManagerImpl throws Exception { super.initialize(rsvc); - Log.log.info("SiteResourceManager initializing."); // the web framework was kind enough to slip this into the runtime when it started up - Application app = (Application)rsvc.getApplicationAttribute( - Application.VELOCITY_ATTR_KEY); + Application app = (Application)rsvc.getApplicationAttribute(Application.VELOCITY_ATTR_KEY); if (app == null) { Log.log.warning("SiteResourceManager: No application was initialized. " + "A user of the site resource manager must ensure that " + "an application is instantiated and initialized."); + return; } + Log.log.info("SiteResourceManager initializing."); // get handles on the good stuff _sctx = app.getServletContext();