Skip to content

Commit 6253e6d

Browse files
tbrugzfpapon
authored andcommitted
[SHIRO-610] Allways create resolver for non-empty IniWebEnvironment
1 parent 83d8dac commit 6253e6d

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

core/src/main/java/org/apache/shiro/env/DefaultEnvironment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public <T> T getObject(String name, Class<T> requiredType) throws RequiredTypeEx
146146
return null;
147147
}
148148
if (!requiredType.isInstance(o)) {
149-
String msg = "Object named '" + name + "' is not of required type [" + requiredType.getName() + "].";
149+
String msg = "Object named '" + name + "' (of type [" + o.getClass().getName() + "]) is not of required type [" + requiredType.getName() + "].";
150150
throw new RequiredTypeException(msg);
151151
}
152152
return (T)o;

web/src/main/java/org/apache/shiro/web/env/IniWebEnvironment.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,13 @@ protected FilterChainResolver createFilterChainResolver() {
259259
Ini ini = getIni();
260260

261261
if (!CollectionUtils.isEmpty(ini)) {
262-
//only create a resolver if the 'filters' or 'urls' sections are defined:
263-
Ini.Section urls = ini.getSection(IniFilterChainResolverFactory.URLS);
264-
Ini.Section filters = ini.getSection(IniFilterChainResolverFactory.FILTERS);
265-
if (!CollectionUtils.isEmpty(urls) || !CollectionUtils.isEmpty(filters)) {
266-
//either the urls section or the filters section was defined. Go ahead and create the resolver:
267-
268-
Factory<FilterChainResolver> factory = (Factory<FilterChainResolver>) this.objects.get(FILTER_CHAIN_RESOLVER_NAME);
269-
if (factory instanceof IniFactorySupport) {
270-
IniFactorySupport iniFactory = (IniFactorySupport) factory;
271-
iniFactory.setIni(ini);
272-
iniFactory.setDefaults(this.objects);
273-
}
274-
resolver = factory.getInstance();
262+
Factory<FilterChainResolver> factory = (Factory<FilterChainResolver>) this.objects.get(FILTER_CHAIN_RESOLVER_NAME);
263+
if (factory instanceof IniFactorySupport) {
264+
IniFactorySupport iniFactory = (IniFactorySupport) factory;
265+
iniFactory.setIni(ini);
266+
iniFactory.setDefaults(this.objects);
275267
}
268+
resolver = factory.getInstance();
276269
}
277270

278271
return resolver;

0 commit comments

Comments
 (0)