Source:
<code>public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { final HttpServletRequest req = (HttpServletRequest) request; final String authHeader = req.getHeader(HTTPConstants.HEADER_AUTHORIZATION); if (StringUtils.isEmpty(authHeader)) { chain.doFilter(request, response); return; } <START> String authType = null; <END> if (authHeader.length() >= AUTH_TYPE_BASIC_LENGTH) { authType = authHeader.trim().substring(0, AUTH_TYPE_BASIC_LENGTH); } if (AUTH_TYPE_BASIC.equals(authType)) { final String authCredentials = (authHeader.trim().substring(AUTH_TYPE_BASIC_LENGTH)).trim(); if (StringUtils.isBlank(authCredentials) || authCredentials.indexOf(' ') >= 0 || authCredentials.length() < MINIMUM_CREDENTIAL_SIZE) { String errorMsg = "Internal Server Error"; handleErrorResponse((HttpServletResponse) response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, errorMsg); } else if (authHeader.substring((AUTH_TYPE_BASIC + " ").length()).startsWith(" ")) { HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(req) { @Override public Enumeration<String> getHeaders(String name) { if (StringUtils.equalsIgnoreCase(name, HTTPConstants.HEADER_AUTHORIZATION)) { Enumeration<String> headerValues = req.getHeaders(name); ArrayList<String> newHeaderValues = new ArrayList<>(); while (headerValues.hasMoreElements()) { String value = headerValues.nextElement(); if (StringUtils.equals(value, authHeader)) { value = AUTH_TYPE_BASIC + " " + authCredentials; newHeaderValues.add(value); } else { newHeaderValues.add(value); } } return Collections.enumeration(newHeaderValues); } return super.getHeaders(name); } }; chain.doFilter(wrapper, response); } else { chain.doFilter(request, response); } } else { chain.doFilter(request, response); } }</code><technical_language>unnecessary null assignment</technical_language>

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { final HttpServletRequest req = (HttpServletRequest) request; final String authHeader = req.getHeader(HTTPConstants.HEADER_AUTHORIZATION); if (StringUtils.isEmpty(authHeader)) { chain.doFilter(request, response); return; } String authType = null; if (authHeader.length() >= AUTH_TYPE_BASIC_LENGTH) { authType = authHeader.trim().substring(0, AUTH_TYPE_BASIC_LENGTH); } if (AUTH_TYPE_BASIC.equals(authType)) { final String authCredentials = (authHeader.trim().substring(AUTH_TYPE_BASIC_LENGTH)).trim(); if (StringUtils.isBlank(authCredentials) || authCredentials.indexOf(' ') >= 0 || authCredentials.length() < MINIMUM_CREDENTIAL_SIZE) { String errorMsg = "Invalid credentials"; handleErrorResponse((HttpServletResponse) response, HttpServletResponse.SC_UNAUTHORIZED, errorMsg); } else if (authHeader.substring((AUTH_TYPE_BASIC + " ").length()).startsWith(" ")) { HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(req) { @Override public Enumeration<String> getHeaders(String name) { if (StringUtils.equalsIgnoreCase(name, HTTPConstants.HEADER_AUTHORIZATION)) { Enumeration<String> headerValues = req.getHeaders(name); ArrayList<String> newHeaderValues = new ArrayList<>(); while (headerValues.hasMoreElements()) { String value = headerValues.nextElement(); if (StringUtils.equals(value, authHeader)) { value = AUTH_TYPE_BASIC + " " + authCredentials; newHeaderValues.add(value); } else { newHeaderValues.add(value); } } return Collections.enumeration(newHeaderValues); } return super.getHeaders(name); } }; chain.doFilter(wrapper, response); } else { chain.doFilter(request, response); } } else { chain.doFilter(request, response); } }