Может ли фильтр сервлетов для управления кэшем создать проблему нехватки памяти? - PullRequest
0 голосов
/ 04 сентября 2018

Я не написал кеш-фильтра для кешируемой ssl-страницы login.do. Мой вопрос здесь: приведет ли этот код к нехватке памяти? потому что, когда я развернул приложение с этим изменением, сервер не запускался, а когда я отключил свое изменение, он начал. Изменения в этом файле создают проблему или могут быть другие проблемы?

web.xml

<filter>
<description>Adding session to log files</description>
<filter-name>SessionUserFilter</filter-name>
<filter-class>com.sanju.filter.SessionUserFilter</filter-class>
</filter>  
 <filter-mapping>
 <filter-name>SessionUserFilter</filter-name>
<url-pattern>/app/login.do</url-pattern> 
  </filter-mapping>

SessionUserFilter class

public class SessionUserFilter implements Filter {
        private FilterConfig filterConfig;

        @Override
        public void init(final FilterConfig filterConfig) {
            this.filterConfig=filterConfig;
        }
        @Override
        public void destroy() {
            this.filterConfig = null;
        }

        @Override
        public void doFilter(final ServletRequest request, final ServletResponse response, FilterChain Chain) throws IOException,ServletException{

            HttpServletRequest httpRequest = (HttpServletRequest) request;
            HttpSession session = httpRequest.getSession(false);

            HttpServletResponse httpResponse = (HttpServletResponse) response;//setting response header value 
            httpResponse.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");//setting no cache in response header 

            httpResponse.setDateHeader("Expires", 0);
            httpResponse.setHeader("Pragma", "No-cache");
            httpResponse.setHeader("Strict-Transport-Security" , "max-age=7776000; includeSubdomains");

            Chain.doFilter(request,response);

            }
    //setters and getter
        public void setFilterConfig(final FilterConfig filterConfig) {
            this.filterConfig = filterConfig;
        }

        public FilterConfig getFilterConfig() {
            return filterConfig;
        }
    }

1 Ответ

0 голосов
/ 06 сентября 2018

В идеале это не должно, но вы можете проверить память при развертывании приложения.

...