Uploaded image for project: 'Shiro'
  1. Shiro
  2. SHIRO-810

DefaultFilterChainManager#addToChain can throw a more specific exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      DefaultFilterChainManager#addToChain throws IllegalArgumentException when the filter is null:

       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);
          }
      

      It is more specific to throw ConfigurationException. Indeed, the following method throws ConfigurationException for the identical reason:

       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);
                  }
              }
          }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            haozhong Hao Zhong
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: