Source:
<code>public String validateRedirectionUri(String clientIdentifier, String redirectionUri) { try { Client client = clientService.getClient(clientIdentifier); if (client != null) { String sectorIdentifierUri = client.getSectorIdentifierUri(); String[] redirectUris = client.getRedirectUris(); if (StringUtils.isNotBlank(sectorIdentifierUri)) { ClientRequest clientRequest = new ClientRequest(sectorIdentifierUri); clientRequest.setHttpMethod(HttpMethod.GET); ClientResponse<String> clientResponse = clientRequest.get(String.class); int status = clientResponse.getStatus(); if (status == 200) { String entity = clientResponse.getEntity(String.class); JSONArray sectorIdentifierJsonArray = new JSONArray(entity); redirectUris = new String[sectorIdentifierJsonArray.length()]; for (int i = 0; i < sectorIdentifierJsonArray.length(); i++) { redirectUris[i] = sectorIdentifierJsonArray.getString(i); } } else { return null; } } if (StringUtils.isNotBlank(redirectionUri)) { log.debug("Validating redirection URI: clientIdentifier = {}, redirectionUri = {}, found = {}", clientIdentifier, redirectionUri, redirectUris != null ? redirectUris.length : 0); final String redirectUriWithoutParams = uriWithoutParams(redirectionUri); <START> <END> for (String uri : redirectUris) { log.debug("Comparing == {}", uri, redirectionUri); if (uri.equals(redirectionUri)) { return redirectionUri; } String uriWithoutParams = uriWithoutParams(uri); final Map<String, String> params = getParams(uri); if ((uriWithoutParams.equals(redirectUriWithoutParams) && params.size() == 0 && getParams(redirectionUri).size() == 0) || uriWithoutParams.equals(redirectUriWithoutParams) && params.size() > 0 && compareParams(redirectionUri, uri)) { return redirectionUri; } } } else { if (redirectUris != null && redirectUris.length == 1) { return redirectUris[0]; } } } } catch (Exception e) { return null; } return null; }</code><technical_language>in line 81 redirectUris in for loop. If is null in line 81 get NPE. means put null check handle correctly</technical_language>

Target:
public String validateRedirectionUri(String clientIdentifier, String redirectionUri) { try { Client client = clientService.getClient(clientIdentifier); if (client != null) { String sectorIdentifierUri = client.getSectorIdentifierUri(); String[] redirectUris = client.getRedirectUris(); if (StringUtils.isNotBlank(sectorIdentifierUri)) { ClientRequest clientRequest = new ClientRequest(sectorIdentifierUri); clientRequest.setHttpMethod(HttpMethod.GET); ClientResponse<String> clientResponse = clientRequest.get(String.class); int status = clientResponse.getStatus(); if (status == 200) { String entity = clientResponse.getEntity(String.class); JSONArray sectorIdentifierJsonArray = new JSONArray(entity); redirectUris = new String[sectorIdentifierJsonArray.length()]; for (int i = 0; i < sectorIdentifierJsonArray.length(); i++) { redirectUris[i] = sectorIdentifierJsonArray.getString(i); } } else { return null; } } if (StringUtils.isNotBlank(redirectionUri) && redirectUris != null) { log.debug("Validating redirection URI: clientIdentifier = {}, redirectionUri = {}, found = {}", clientIdentifier, redirectionUri, redirectUris.length); final String redirectUriWithoutParams = uriWithoutParams(redirectionUri); for (String uri : redirectUris) { log.debug("Comparing == {}", uri, redirectionUri); if (uri.equals(redirectionUri)) { return redirectionUri; } String uriWithoutParams = uriWithoutParams(uri); final Map<String, String> params = getParams(uri); if ((uriWithoutParams.equals(redirectUriWithoutParams) && params.size() == 0 && getParams(redirectionUri).size() == 0) || uriWithoutParams.equals(redirectUriWithoutParams) && params.size() > 0 && compareParams(redirectionUri, uri)) { return redirectionUri; } } } else { if (redirectUris != null && redirectUris.length == 1) { return redirectUris[0]; } } } } catch (Exception e) { return null; } return null; }