code: public static boolean hasFilter(Filter filter) {
          Jenkins j = Jenkins.getInstanceOrNull();
          PluginServletFilter container = null;
          if(j != null) {
              container = getInstance(j.servletContext);
          }
          if (j == null || container == null) {
              return LEGACY.contains(filter);
          } else {
              return container.list.contains(filter);
          }
      }
docs: Checks whether the given filter is already registered in the chain.
  @param filter the filter to check.
  @return true if the filter is already registered in the chain.
  @since 2.94