@@ -42,19 +42,20 @@ public FilterableAttribute(String[] patterns) {
42
42
}
43
43
44
44
public FilterableAttribute (
45
- String [] patterns , boolean facetSearch , Map <String , Boolean > filters ) {
46
- if (patterns == null ) throw new IllegalArgumentException ("Patterns cannot be null" );
47
- boolean patternHasGeo = false ;
48
- for (String s : patterns )
49
- if (_GEO .equals (s )) {
50
- patternHasGeo = true ;
51
- break ;
52
- }
53
- if (patternHasGeo ) checkGeoValidation (facetSearch , filters );
54
- this .patterns = patterns ;
55
- this .facetSearch = facetSearch ;
56
- this .filter = filters ;
57
- }
45
+ public FilterableAttribute (String [] patterns , boolean facetSearch , Map <String , Boolean > filters ) {
46
+ if (patterns == null ) throw new IllegalArgumentException ("Patterns cannot be null" );
47
+ if (filters == null ) throw new IllegalArgumentException ("Filters cannot be null" );
48
+ boolean patternHasGeo = false ;
49
+ for (String s : patterns )
50
+ if (_GEO .equals (s )) {
51
+ patternHasGeo = true ;
52
+ break ;
53
+ }
54
+ if (patternHasGeo ) checkGeoValidation (facetSearch , filters );
55
+ this .patterns = Arrays .copyOf (patterns , patterns .length ); // defensive copy
56
+ this .facetSearch = facetSearch ;
57
+ this .filter = new HashMap <>(filters ); // defensive copy
58
+ }
58
59
59
60
private static void checkGeoValidation (boolean facetSearch , Map <String , Boolean > filters ) {
60
61
String [] errors = new String [3 ];
0 commit comments