Github user benchristel commented on a diff in the pull request: https://github.com/apache/incubator-hawq/pull/1379#discussion_r202824082 --- Diff: pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/servlet/SecurityServletFilter.java --- @@ -19,94 +19,114 @@ * under the License. */ - import java.io.IOException; import java.lang.reflect.UndeclaredThrowableException; import java.security.PrivilegedExceptionAction; -import javax.servlet.*; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.security.UserGroupInformation; +import org.apache.hawq.pxf.service.SessionId; +import org.apache.hawq.pxf.service.UGICache; import org.apache.hawq.pxf.service.utilities.SecureLogin; - /** * Listener on lifecycle events of our webapp */ public class SecurityServletFilter implements Filter { private static final Log LOG = LogFactory.getLog(SecurityServletFilter.class); private static final String USER_HEADER = "X-GP-USER"; - private static final String MISSING_HEADER_ERROR = String.format("Header %s is missing in the request", USER_HEADER); - private static final String EMPTY_HEADER_ERROR = String.format("Header %s is empty in the request", USER_HEADER); + private static final String SEGMENT_ID_HEADER = "X-GP-SEGMENT-ID"; + private static final String TRANSACTION_ID_HEADER = "X-GP-XID"; + private static final String FRAGMENT_INDEX_HEADER = "X-GP-FRAGMENT-INDEX"; + private static final String FRAGMENT_COUNT_HEADER = "X-GP-FRAGMENT-COUNT"; + private static final String MISSING_HEADER_ERROR = "Header %s is missing in the request"; + private static final String EMPTY_HEADER_ERROR = "Header %s is empty in the request"; + private static UGICache proxyUGICache; --- End diff -- @denalex @lavjain What is the lifetime of the `SecurityServletFilter` instance? As I was thinking about making this non-static, I realized that if there's more than one instance per JVM, we might get redundant caches (and possible UGI resource leaks, if a `SecurityServletFilter` gets garbage-collected before all the UGIs in its cache are cleaned up).
---