2222
2323/**
2424 * A filter to be used by JXPath, to evaluate the xpath string values to impose any restrictions.
25- * This class implements specific filter interfaces, and implements methods in those.
25+ * This class implements specific filter interfaces, and implements methods in those.
2626 * For instance, it JXPathClassFilter interface, which is used to check if any restricted java classes are passed via xpath
2727 * JXPath uses this filter instance when an extension function instance is created.
2828 */
2929public class JXPathFilter implements JXPathClassFilter {
30- private Set <String > allowedClassesList = null ;
30+ private final Set <String > allowedClasses ;
3131
3232 public JXPathFilter () {
33- init ();
34- }
35-
36- public void init () {
33+ this .allowedClasses = new HashSet <>();
3734 final String allowedClasses = System .getProperty ("jxpath.class.allow" );
3835 if (allowedClasses != null && !allowedClasses .isEmpty ()) {
39- allowedClassesList = new HashSet <>();
40- allowedClassesList .addAll (Arrays .asList (allowedClasses .split ("," )));
36+ this .allowedClasses .addAll (Arrays .asList (allowedClasses .split ("," )));
4137 }
4238 }
4339
@@ -50,10 +46,10 @@ public void init() {
5046 */
5147 @ Override
5248 public boolean exposeToXPath (String className ) {
53- if (allowedClassesList == null || allowedClassesList . size () < 1 ) {
49+ if (allowedClasses . isEmpty () ) {
5450 return false ;
5551 }
5652
57- return allowedClassesList .contains (className ) || allowedClassesList .contains ("*" );
53+ return allowedClasses .contains (className ) || allowedClasses .contains ("*" );
5854 }
5955}
0 commit comments