Search code examples
javaservletsmemoryfilterdestroy

filter.destroy() method's api description of servlet


when i'm looking for the filter.destroy() method's api description of servlet, i found a description like below "This method gives the filter an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the filter's current state in memory."

but i don't understand what is "make sure that any persistent state is synchronized with the filter's current state in memory" means,what is the persistent state and filter's current state means?

ps:and it seems that this description also be mentioned in the servlet's destroy() method

thanks


Solution

  • It means it will clean all the data stored n memory related to the filters, for example the list of urls to allow, the list of urls to block, the list of URLs to for which some processing has to apply etc. Sometimes it needs to have the users security context to take action (i.e whether to block or allow) all these things will be released during a filter destroy.