@@ -36,7 +36,7 @@ public String toString() {
3636 }
3737
3838 private List <Map <String , String >> collectFiltersData (Object context ) {
39- Map < String , Map <String , Object >> aggregatedData = new LinkedHashMap <>();
39+ List < Map <String , String >> result = new ArrayList <>();
4040 try {
4141 Object servletHandler = getFieldValue (context , "_servletHandler" );
4242 if (servletHandler == null ) return Collections .emptyList ();
@@ -46,54 +46,35 @@ private List<Map<String, String>> collectFiltersData(Object context) {
4646 for (Object mapping : filterMappings ) {
4747 String name = (String ) invokeMethod (mapping , "getFilterName" );
4848 if (name == null ) continue ;
49- if (!aggregatedData .containsKey (name )) {
50- String filterClass = "N/A" ;
51- if (filterHolders != null ) {
52- for (Object holder : filterHolders ) {
53- String holderName = (String ) invokeMethod (holder , "getName" );
54- if (!name .equals (holderName )) continue ;
55- String cls = (String ) invokeMethod (holder , "getClassName" );
56- if (cls == null ) {
57- Object filterInstance = invokeMethod (holder , "getFilter" );
58- if (filterInstance != null ) {
59- cls = filterInstance .getClass ().getName ();
60- }
49+ String filterClass = "N/A" ;
50+ if (filterHolders != null ) {
51+ for (Object holder : filterHolders ) {
52+ String holderName = (String ) invokeMethod (holder , "getName" );
53+ if (!name .equals (holderName )) continue ;
54+ String cls = (String ) invokeMethod (holder , "getClassName" );
55+ if (cls == null ) {
56+ Object filterInstance = invokeMethod (holder , "getFilter" );
57+ if (filterInstance != null ) {
58+ cls = filterInstance .getClass ().getName ();
6159 }
62-
63- if (cls != null ) filterClass = cls ;
64- break ;
6560 }
61+
62+ if (cls != null ) filterClass = cls ;
63+ break ;
6664 }
67- Map <String , Object > info = new HashMap <>();
68- info .put ("filterName" , name );
69- info .put ("filterClass" , filterClass );
70- info .put ("urlPatterns" , new LinkedHashSet <String >());
71- aggregatedData .put (name , info );
7265 }
73- Map <String , Object > info = aggregatedData .get (name );
74- String [] pathSpecs = null ;
66+ Map <String , String > info = new HashMap <>();
67+ info .put ("filterName" , name );
68+ info .put ("filterClass" , filterClass );
7569 try {
76- pathSpecs = (String []) invokeMethod (mapping , "getPathSpecs" );
70+ String [] pathSpecs = (String []) invokeMethod (mapping , "getPathSpecs" );
71+ info .put ("urlPatterns" , pathSpecs .length == 0 ? "" : Arrays .toString (pathSpecs ));
7772 } catch (Exception ignored ) {
7873 }
79-
80- if (pathSpecs != null ) {
81- ((Set <String >) info .get ("urlPatterns" )).addAll (Arrays .asList (pathSpecs ));
82- }
74+ result .add (info );
8375 }
8476 } catch (Exception ignored ) {
8577 }
86- List <Map <String , String >> result = new ArrayList <>();
87- for (Map <String , Object > entry : aggregatedData .values ()) {
88- Map <String , String > finalInfo = new HashMap <>();
89- finalInfo .put ("filterName" , (String ) entry .get ("filterName" ));
90- finalInfo .put ("filterClass" , (String ) entry .get ("filterClass" ));
91-
92- Set <?> urls = (Set <?>) entry .get ("urlPatterns" );
93- finalInfo .put ("urlPatterns" , urls .isEmpty () ? "" : urls .toString ());
94-
95- result .add (finalInfo );
96- }
9778 return result ;
9879 }
9980
0 commit comments