Skip to content

Commit

Permalink
Make PR easier to read with a whitespace tweak.
Browse files Browse the repository at this point in the history
  • Loading branch information
lionell-pack-ttd committed Feb 1, 2024
1 parent e852463 commit 3265958
Showing 1 changed file with 52 additions and 52 deletions.
104 changes: 52 additions & 52 deletions src/main/java/com/uid2/optout/partner/OptOutPartnerEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,59 +53,59 @@ public String name() {
public Future<Void> send(OptOutEntry entry) {
long startTimeMs = System.currentTimeMillis();
return this.retryingClient.send(
(URI uri, HttpMethod method) -> {
URIBuilder uriBuilder = new URIBuilder(uri);

for (String queryParam : config.queryParams()) {
int indexOfEqualSign = queryParam.indexOf('=');
String paramName = queryParam.substring(0, indexOfEqualSign);
String paramValue = queryParam.substring(indexOfEqualSign + 1);
String replacedValue = replaceValueReferences(entry, paramValue);

uriBuilder.addParameter(paramName, replacedValue);
}

URI uriWithParams;
try {
uriWithParams = uriBuilder.build();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}

HttpRequest.Builder builder = HttpRequest.newBuilder()
.uri(uriWithParams)
.method(method.toString(), HttpRequest.BodyPublishers.noBody());

for (String additionalHeader : this.config.additionalHeaders()) {
int indexOfColonSign = additionalHeader.indexOf(':');
String headerName = additionalHeader.substring(0, indexOfColonSign);
String headerValue = additionalHeader.substring(indexOfColonSign + 1);
String replacedValue = replaceValueReferences(entry, headerValue);
builder.header(headerName, replacedValue);
}

LOGGER.info("replaying optout " + config.url() + " - advertising_id: " + Utils.maskPii(entry.advertisingId) + ", epoch: " + entry.timestamp);

return builder.build();
},
resp -> {
if (resp == null) {
throw new RuntimeException("response is null");
}

if (SUCCESS_STATUS_CODES.contains(resp.statusCode())) {
long finishTimeMs = System.currentTimeMillis();
timer.record(finishTimeMs - startTimeMs, TimeUnit.MILLISECONDS);
return true;
}

LOGGER.info("received non-200 response: " + resp.statusCode() + "-" + resp.body() + " for optout " + config.url() + " - advertising_id: " + Utils.maskPii(entry.advertisingId) + ", epoch: " + entry.timestamp);
if (RETRYABLE_STATUS_CODES.contains(resp.statusCode())) {
return false;
} else {
throw new UnexpectedStatusCodeException(resp.statusCode());
}
(URI uri, HttpMethod method) -> {
URIBuilder uriBuilder = new URIBuilder(uri);

for (String queryParam : config.queryParams()) {
int indexOfEqualSign = queryParam.indexOf('=');
String paramName = queryParam.substring(0, indexOfEqualSign);
String paramValue = queryParam.substring(indexOfEqualSign + 1);
String replacedValue = replaceValueReferences(entry, paramValue);

uriBuilder.addParameter(paramName, replacedValue);
}

URI uriWithParams;
try {
uriWithParams = uriBuilder.build();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}

HttpRequest.Builder builder = HttpRequest.newBuilder()
.uri(uriWithParams)
.method(method.toString(), HttpRequest.BodyPublishers.noBody());

for (String additionalHeader : this.config.additionalHeaders()) {
int indexOfColonSign = additionalHeader.indexOf(':');
String headerName = additionalHeader.substring(0, indexOfColonSign);
String headerValue = additionalHeader.substring(indexOfColonSign + 1);
String replacedValue = replaceValueReferences(entry, headerValue);
builder.header(headerName, replacedValue);
}

LOGGER.info("replaying optout " + config.url() + " - advertising_id: " + Utils.maskPii(entry.advertisingId) + ", epoch: " + entry.timestamp);

return builder.build();
},
resp -> {
if (resp == null) {
throw new RuntimeException("response is null");
}

if (SUCCESS_STATUS_CODES.contains(resp.statusCode())) {
long finishTimeMs = System.currentTimeMillis();
timer.record(finishTimeMs - startTimeMs, TimeUnit.MILLISECONDS);
return true;
}

LOGGER.info("received non-200 response: " + resp.statusCode() + "-" + resp.body() + " for optout " + config.url() + " - advertising_id: " + Utils.maskPii(entry.advertisingId) + ", epoch: " + entry.timestamp);
if (RETRYABLE_STATUS_CODES.contains(resp.statusCode())) {
return false;
} else {
throw new UnexpectedStatusCodeException(resp.statusCode());
}
}
);
}

Expand Down

0 comments on commit 3265958

Please sign in to comment.