Skip to content

Commit

Permalink
Merge pull request #242 from tbrugz/SHIRO-610b
Browse files Browse the repository at this point in the history
[SHIRO-610] Allways create resolver for non-empty IniWebEnvironment
  • Loading branch information
fpapon authored Jul 22, 2020
2 parents acef145 + bffaa33 commit 6c4e8f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public <T> T getObject(String name, Class<T> requiredType) throws RequiredTypeEx
return null;
}
if (!requiredType.isInstance(o)) {
String msg = "Object named '" + name + "' is not of required type [" + requiredType.getName() + "].";
String msg = "Object named '" + name + "' (of type [" + o.getClass().getName() + "]) is not of required type [" + requiredType.getName() + "].";
throw new RequiredTypeException(msg);
}
return (T)o;
Expand Down
19 changes: 6 additions & 13 deletions web/src/main/java/org/apache/shiro/web/env/IniWebEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,13 @@ protected FilterChainResolver createFilterChainResolver() {
Ini ini = getIni();

if (!CollectionUtils.isEmpty(ini)) {
//only create a resolver if the 'filters' or 'urls' sections are defined:
Ini.Section urls = ini.getSection(IniFilterChainResolverFactory.URLS);
Ini.Section filters = ini.getSection(IniFilterChainResolverFactory.FILTERS);
if (!CollectionUtils.isEmpty(urls) || !CollectionUtils.isEmpty(filters)) {
//either the urls section or the filters section was defined. Go ahead and create the resolver:

Factory<FilterChainResolver> factory = (Factory<FilterChainResolver>) this.objects.get(FILTER_CHAIN_RESOLVER_NAME);
if (factory instanceof IniFactorySupport) {
IniFactorySupport iniFactory = (IniFactorySupport) factory;
iniFactory.setIni(ini);
iniFactory.setDefaults(this.objects);
}
resolver = factory.getInstance();
Factory<FilterChainResolver> factory = (Factory<FilterChainResolver>) this.objects.get(FILTER_CHAIN_RESOLVER_NAME);
if (factory instanceof IniFactorySupport) {
IniFactorySupport iniFactory = (IniFactorySupport) factory;
iniFactory.setIni(ini);
iniFactory.setDefaults(this.objects);
}
resolver = factory.getInstance();
}

return resolver;
Expand Down

0 comments on commit 6c4e8f1

Please sign in to comment.