You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by "Benjamin Marwell (Jira)" <ji...@apache.org> on 2021/01/20 06:52:00 UTC
[jira] [Commented] (SHIRO-810) DefaultFilterChainManager#addToChain
can throw a more specific exception
[ https://issues.apache.org/jira/browse/SHIRO-810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17268399#comment-17268399 ]
Benjamin Marwell commented on SHIRO-810:
----------------------------------------
Thanks for mentioning! Because this is (probably) an API change, we can target this for 2.0.0.
Would you be willing to create a PR on GitHub?
> DefaultFilterChainManager#addToChain can throw a more specific exception
> ------------------------------------------------------------------------
>
> Key: SHIRO-810
> URL: https://issues.apache.org/jira/browse/SHIRO-810
> Project: Shiro
> Issue Type: Bug
> Reporter: Hao Zhong
> Priority: Major
>
> DefaultFilterChainManager#addToChain throws IllegalArgumentException when the filter is null:
> {code:java}
> public void addToChain(String chainName, String filterName, String chainSpecificFilterConfig) {
> if (!StringUtils.hasText(chainName)) {
> throw new IllegalArgumentException("chainName cannot be null or empty.");
> }
> Filter filter = getFilter(filterName);
> if (filter == null) {
> throw new IllegalArgumentException("There is no filter with name '" + filterName +
> "' to apply to chain [" + chainName + "] in the pool of available Filters. Ensure a " +
> "filter with that name/path has first been registered with the addFilter method(s).");
> } applyChainConfig(chainName, filter, chainSpecificFilterConfig); NamedFilterList chain = ensureChain(chainName);
> chain.add(filter);
> }
> {code}
> It is more specific to throw ConfigurationException. Indeed, the following method throws ConfigurationException for the identical reason:
> {code:java}
> public void setGlobalFilters(List<String> globalFilterNames) throws ConfigurationException {
> // validate each filter name
> if (!CollectionUtils.isEmpty(globalFilterNames)) {
> for (String filterName : globalFilterNames) {
> Filter filter = filters.get(filterName);
> if (filter == null) {
> throw new ConfigurationException("There is no filter with name '" + filterName +
> "' to apply to the global filters in the pool of available Filters. Ensure a " +
> "filter with that name/path has first been registered with the addFilter method(s).");
> }
> this.globalFilterNames.add(filterName);
> }
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)