Skip to content

Commit

Permalink
Simplify. Fix naming of message keys (s/Resources/Resource/). Log nam…
Browse files Browse the repository at this point in the history
…e of a missing resource.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1722905 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Konstantin Kolinko committed Jan 4, 2016
1 parent 1cef2b1 commit 629c6cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
19 changes: 8 additions & 11 deletions java/org/apache/catalina/core/DefaultInstanceManager.java
Expand Up @@ -88,19 +88,16 @@ public DefaultInstanceManager(Context context,
privileged = catalinaContext.getPrivileged();
this.containerClassLoader = containerClassLoader;
ignoreAnnotations = catalinaContext.getIgnoreAnnotations();
StringManager sm = StringManager.getManager(Constants.Package);
Log log = catalinaContext.getLogger();
restrictedServlets = loadProperties(
"org/apache/catalina/core/RestrictedServlets.properties",
sm.getString("defaultInstanceManager.restrictedServletsResource"),
catalinaContext.getLogger());
"defaultInstanceManager.restrictedServletsResource", log);
restrictedListeners = loadProperties(
"org/apache/catalina/core/RestrictedListeners.properties",
sm.getString("defaultInstanceManager.restrictedListenersResources"),
catalinaContext.getLogger());
"defaultInstanceManager.restrictedListenersResource", log);
restrictedFilters = loadProperties(
"org/apache/catalina/core/RestrictedFilters.properties",
sm.getString("defaultInstanceManager.restrictedFiltersResource"),
catalinaContext.getLogger());
"defaultInstanceManager.restrictedFiltersResource", log);
this.context = context;
this.injectionMap = injectionMap;
this.postConstructMethods = catalinaContext.findPostConstructMethods();
Expand Down Expand Up @@ -624,17 +621,17 @@ protected static void lookupMethodResource(Context context,
}
}

private static Properties loadProperties(String resourceName, String errorString, Log log) {
private static Properties loadProperties(String resourceName, String messageKey, Log log) {
Properties result = new Properties();
ClassLoader cl = DefaultInstanceManager.class.getClassLoader();
try (InputStream is = cl.getResourceAsStream(resourceName)) {
if (is ==null) {
log.error(errorString);
if (is == null) {
log.error(sm.getString(messageKey, resourceName));
} else {
result.load(is);
}
} catch (IOException ioe) {
log.error(errorString, ioe);
log.error(sm.getString(messageKey, resourceName), ioe);
}
return result;
}
Expand Down
6 changes: 3 additions & 3 deletions java/org/apache/catalina/core/LocalStrings.properties
Expand Up @@ -222,6 +222,6 @@ threadLocalLeakPreventionListener.lifecycleEvent.error=Exception processing life
threadLocalLeakPreventionListener.containerEvent.error=Exception processing container event {0}

defaultInstanceManager.invalidInjection=Invalid method resource injection annotation
defaultInstanceManager.restrictedServletsResource=Restricted servlets property file not found
defaultInstanceManager.restrictedFiltersResource=Restricted filters property file not found
defaultInstanceManager.restrictedListenersResources=Restricted listeners property file not found
defaultInstanceManager.restrictedFiltersResource=Restricted filters property file not found [{0}]
defaultInstanceManager.restrictedListenersResource=Restricted listeners property file not found [{0}]
defaultInstanceManager.restrictedServletsResource=Restricted servlets property file not found [{0}]

0 comments on commit 629c6cd

Please sign in to comment.