Skip to content

Commit

Permalink
fix japicmp check for threadContext (opensearch-project#14147)
Browse files Browse the repository at this point in the history
Signed-off-by: Chenyang Ji <[email protected]>
  • Loading branch information
ansjcy authored Jun 10, 2024
1 parent 04a417a commit 1ac9d6f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public <T> T getTransient(String key) {
* @param value the header value
*/
public void addResponseHeader(final String key, final String value) {
updateResponseHeader(key, value, v -> v, false);
addResponseHeader(key, value, v -> v);
}

/**
Expand All @@ -490,7 +490,19 @@ public void addResponseHeader(final String key, final String value) {
* @param value the header value
*/
public void updateResponseHeader(final String key, final String value) {
updateResponseHeader(key, value, v -> v, true);
updateResponseHeader(key, value, v -> v);
}

/**
* Add the {@code value} for the specified {@code key} with the specified {@code uniqueValue} used for de-duplication. Any duplicate
* {@code value} after applying {@code uniqueValue} is ignored.
*
* @param key the header name
* @param value the header value
* @param uniqueValue the function that produces de-duplication values
*/
public void addResponseHeader(final String key, final String value, final Function<String, String> uniqueValue) {
threadLocal.set(threadLocal.get().putResponse(key, value, uniqueValue, maxWarningHeaderCount, maxWarningHeaderSize, false));
}

/**
Expand All @@ -500,17 +512,9 @@ public void updateResponseHeader(final String key, final String value) {
* @param key the header name
* @param value the header value
* @param uniqueValue the function that produces de-duplication values
* @param replaceExistingKey whether to replace the existing header if it already exists
*/
public void updateResponseHeader(
final String key,
final String value,
final Function<String, String> uniqueValue,
final boolean replaceExistingKey
) {
threadLocal.set(
threadLocal.get().putResponse(key, value, uniqueValue, maxWarningHeaderCount, maxWarningHeaderSize, replaceExistingKey)
);
*/
public void updateResponseHeader(final String key, final String value, final Function<String, String> uniqueValue) {
threadLocal.set(threadLocal.get().putResponse(key, value, uniqueValue, maxWarningHeaderCount, maxWarningHeaderSize, true));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,11 @@ public void testResponseHeaders() {
}

final String value = HeaderWarning.formatWarning("qux");
threadContext.updateResponseHeader("baz", value, s -> HeaderWarning.extractWarningValueFromWarningHeader(s, false), false);
threadContext.updateResponseHeader("baz", value, s -> HeaderWarning.extractWarningValueFromWarningHeader(s, false));
// pretend that another thread created the same response at a different time
if (randomBoolean()) {
final String duplicateValue = HeaderWarning.formatWarning("qux");
threadContext.updateResponseHeader(
"baz",
duplicateValue,
s -> HeaderWarning.extractWarningValueFromWarningHeader(s, false),
false
);
threadContext.updateResponseHeader("baz", duplicateValue, s -> HeaderWarning.extractWarningValueFromWarningHeader(s, false));
}

threadContext.addResponseHeader("Warning", "One is the loneliest number");
Expand Down

0 comments on commit 1ac9d6f

Please sign in to comment.