Skip to content

Commit

Permalink
Avoid NPE in ContextLoader when dealing with an untyped ApplicationCo…
Browse files Browse the repository at this point in the history
…ntextInitializer

Issue: SPR-10449
  • Loading branch information
jhoeller committed May 16, 2013
1 parent c8b071c commit a19c976
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ protected Class<?> determineContextClass(ServletContext servletContext) {
protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) {
List<Class<ApplicationContextInitializer<ConfigurableApplicationContext>>> initializerClasses =
determineContextInitializerClasses(servletContext);

if (initializerClasses.size() == 0) {
// no ApplicationContextInitializers have been declared -> nothing to do
return;
Expand All @@ -483,11 +482,13 @@ protected void customizeContext(ServletContext servletContext, ConfigurableWebAp
for (Class<ApplicationContextInitializer<ConfigurableApplicationContext>> initializerClass : initializerClasses) {
Class<?> initializerContextClass =
GenericTypeResolver.resolveTypeArgument(initializerClass, ApplicationContextInitializer.class);
Assert.isAssignable(initializerContextClass, contextClass, String.format(
"Could not add context initializer [%s] as its generic parameter [%s] " +
"is not assignable from the type of application context used by this " +
"context loader [%s]: ", initializerClass.getName(), initializerContextClass.getName(),
contextClass.getName()));
if (initializerContextClass != null) {
Assert.isAssignable(initializerContextClass, contextClass, String.format(
"Could not add context initializer [%s] as its generic parameter [%s] " +
"is not assignable from the type of application context used by this " +
"context loader [%s]: ", initializerClass.getName(), initializerContextClass.getName(),
contextClass.getName()));
}
initializerInstances.add(BeanUtils.instantiateClass(initializerClass));
}

Expand Down

0 comments on commit a19c976

Please sign in to comment.