From b86a34b61137d97210dd7f56051fe46f9cdd2ad6 Mon Sep 17 00:00:00 2001 From: j2blake Date: Thu, 6 Jun 2013 18:09:13 -0400 Subject: [PATCH] VIVO-73 Check for null Set from ServletContext.getResourcePaths() --- .../selection/LocaleSelectorUtilities.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectorUtilities.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectorUtilities.java index 0e5eeb492..d7f93f937 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectorUtilities.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/selection/LocaleSelectorUtilities.java @@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.i18n.selection; import java.io.FileNotFoundException; import java.util.Locale; +import java.util.Set; import javax.servlet.ServletContext; @@ -40,13 +41,16 @@ public class LocaleSelectorUtilities { String imageDirPath = "/" + themeDir + "i18n/images/"; ServletContext ctx = vreq.getSession().getServletContext(); - for (Object o : ctx.getResourcePaths(imageDirPath)) { - String resourcePath = (String) o; - if (resourcePath.contains(filename)) { - String fullPath = vreq.getContextPath() + resourcePath; - log.debug("Found image for " + locale + " at '" + fullPath - + "'"); - return fullPath; + @SuppressWarnings("unchecked") + Set resourcePaths = ctx.getResourcePaths(imageDirPath); + if (resourcePaths != null) { + for (String resourcePath : resourcePaths) { + if (resourcePath.contains(filename)) { + String fullPath = vreq.getContextPath() + resourcePath; + log.debug("Found image for " + locale + " at '" + fullPath + + "'"); + return fullPath; + } } } throw new FileNotFoundException("Can't find an image for " + locale);