OpenNTF / org.openntf.xsp.jakartaee

XPages Jakarta EE support libraries
Apache License 2.0
20 stars 7 forks source link

Consider making a delegating JNDI ValidatorFactory #580

Open jesse-gallagher opened 2 weeks ago

jesse-gallagher commented 2 weeks ago

JakartaRestServlet contains this routine:

context.rebind("java:comp/ValidatorFactory", fac); //$NON-NLS-1$
try {
    delegate.service(request, response);
} finally {
    try {
        context.unbind("java:comp/ValidatorFactory"); //$NON-NLS-1$
    } catch(NamingException e) {
        // Ignore unbind exceptions
    }
}

This is potentially trouble in that it's pushing a logically thread-specific value into a global namespace. It would also be useful in general to have a ValidatorFactory at its expected JNDI location at all times for various specs.

jesse-gallagher commented 2 weeks ago

Such an implementation should take care to look for any active XPages-specific one first, since that can use the XPages-specific locale. Along those lines, it could be good for a general validator to look for a locale in an active ServletRequest.