test_class.file: micro-ip-tracker/src/test/java/com/oath/micro/server/ip/tracker/QueryIPRetrieverTest.java
test_class.identifier: QueryIPRetrieverTest
test_case.body: @Test
  	public void testDoFilter() throws IOException, ServletException {
  
  		ServletRequest request = mock(ServletRequest.class);
  		ServletResponse response = mock(ServletResponse.class);
  
  		when(request.getRemoteAddr()).thenReturn("10.10.11.11");
  
  		QueryIPRetriever queryIPRetriever = new QueryIPRetriever();
  		MyFilterChain myFilterChain = new MyFilterChain();
  		
  		myFilterChain.setQueryIPRetriever(queryIPRetriever);
  
  		queryIPRetriever.doFilter(request, response, myFilterChain);
  
  		assertEquals("IP address not equal", "10.10.11.11",	myFilterChain.getIpAddress());
  		assertNull(QueryIPRetriever.getIpAddress());
  
  	}
test_case.class_method_signature: QueryIPRetrieverTest.testDoFilter()
test_case.full_signature: @Test public void testDoFilter()
test_case.identifier: testDoFilter
test_case.invocations: mock mock thenReturn when getRemoteAddr setQueryIPRetriever doFilter assertEquals getIpAddress assertNull getIpAddress
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testDoFilter()
focal_class.declarator: logger = LoggerFactory.getLogger(this.getClass())
focal_class.modifier: private final
focal_class.original_string: private final Logger logger = LoggerFactory.getLogger(this.getClass());
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: ipForwardingHeader
focal_class.modifier: private
focal_class.original_string: private  String ipForwardingHeader;
focal_class.type: String
focal_class.var_name: ipForwardingHeader
focal_class.declarator: mappings
focal_class.modifier: private
focal_class.original_string: private String[] mappings;
focal_class.type: String[]
focal_class.var_name: mappings
focal_class.declarator: ipAddress = new ThreadLocal<String>()
focal_class.modifier: private static final
focal_class.original_string: private static final ThreadLocal<String> ipAddress = new ThreadLocal<String>();
focal_class.type: ThreadLocal<String>
focal_class.var_name: ipAddress
focal_class.file: micro-ip-tracker/src/main/java/com/oath/micro/server/ip/tracker/QueryIPRetriever.java
focal_class.identifier: QueryIPRetriever
focal_class.interfaces: implements Filter
focal_class.class_method_signature: QueryIPRetriever.QueryIPRetriever(String ipForwardingHeaderValue, 
  							String[] mappingsValue)
focal_class.full_signature: public  QueryIPRetriever(String ipForwardingHeaderValue, 
  							String[] mappingsValue)
focal_class.identifier: QueryIPRetriever
focal_class.modifiers: public
focal_class.parameters: (String ipForwardingHeaderValue, 
  							String[] mappingsValue)
focal_class.signature:  QueryIPRetriever(String ipForwardingHeaderValue, 
  							String[] mappingsValue)
focal_class.class_method_signature: QueryIPRetriever.QueryIPRetriever()
focal_class.full_signature: public  QueryIPRetriever()
focal_class.identifier: QueryIPRetriever
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  QueryIPRetriever()
focal_class.class_method_signature: QueryIPRetriever.getIpAddress()
focal_class.full_signature: public static String getIpAddress()
focal_class.identifier: getIpAddress
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getIpAddress()
focal_class.class_method_signature: QueryIPRetriever.doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
focal_class.full_signature: @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
focal_class.identifier: doFilter
focal_class.modifiers: @Override public
focal_class.parameters: (ServletRequest request, ServletResponse response, FilterChain chain)
focal_class.return: void
focal_class.signature: void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
focal_class.class_method_signature: QueryIPRetriever.getVipClientIP(ServletRequest request)
focal_class.full_signature: private Optional<String> getVipClientIP(ServletRequest request)
focal_class.identifier: getVipClientIP
focal_class.modifiers: private
focal_class.parameters: (ServletRequest request)
focal_class.return: Optional<String>
focal_class.signature: Optional<String> getVipClientIP(ServletRequest request)
focal_class.class_method_signature: QueryIPRetriever.isBlank(final String str)
focal_class.full_signature: private boolean isBlank(final String str)
focal_class.identifier: isBlank
focal_class.modifiers: private
focal_class.parameters: (final String str)
focal_class.return: boolean
focal_class.signature: boolean isBlank(final String str)
focal_class.class_method_signature: QueryIPRetriever.init(FilterConfig filterConfig)
focal_class.full_signature: @Override public void init(FilterConfig filterConfig)
focal_class.identifier: init
focal_class.modifiers: @Override public
focal_class.parameters: (FilterConfig filterConfig)
focal_class.return: void
focal_class.signature: void init(FilterConfig filterConfig)
focal_class.class_method_signature: QueryIPRetriever.destroy()
focal_class.full_signature: @Override public void destroy()
focal_class.identifier: destroy
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void destroy()
focal_method.body: @Override
  	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  		try {
  			Optional<String> vipClientIP = getVipClientIP(request);
  			if (vipClientIP.isPresent()) {
  				ipAddress.set(vipClientIP.get());
  			} else {
  				String remoteAddr = request.getRemoteAddr();
  				logger.debug( "remoteAddr: " + remoteAddr);
  				ipAddress.set(remoteAddr);
  			}
  			chain.doFilter(request, response);
  		} finally {
  			ipAddress.remove();
  		}
  	}
focal_method.class_method_signature: QueryIPRetriever.doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
focal_method.full_signature: @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
focal_method.identifier: doFilter
focal_method.invocations: getVipClientIP isPresent set get getRemoteAddr debug set doFilter remove
focal_method.modifiers: @Override public
focal_method.parameters: (ServletRequest request, ServletResponse response, FilterChain chain)
focal_method.return: void
focal_method.signature: void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)