Skip to content

Commit

Permalink
Workaround for https://bugs.openjdk.org/browse/JDK-8323659 regression…
Browse files Browse the repository at this point in the history
…, introduced in JDK-21.0.2 (#11968)

Signed-off-by: Andriy Redko <[email protected]>
(cherry picked from commit 48fdb4f)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Jan 23, 2024
1 parent c40fcff commit 2be4c6c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Use slice_size == shard_size heuristic in terms aggs for concurrent segment search and properly calculate the doc_count_error ([#11732](https://github.com/opensearch-project/OpenSearch/pull/11732))
- Ensure Jackson default maximums introduced in 2.16.0 do not conflict with OpenSearch settings ([#11890](https://github.com/opensearch-project/OpenSearch/pull/11890))
- Extract cluster management for integration tests into JUnit test rule out of OpenSearchIntegTestCase ([#11877](https://github.com/opensearch-project/OpenSearch/pull/11877))
- Workaround for https://bugs.openjdk.org/browse/JDK-8323659 regression, introduced in JDK-21.0.2 ([#11968](https://github.com/opensearch-project/OpenSearch/pull/11968))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,30 @@ public boolean offer(E e) {
}
}

/**
* Workaround for https://bugs.openjdk.org/browse/JDK-8323659 regression, introduced in JDK-21.0.2.
*/
@Override
public void put(E e) {
super.offer(e);
}

/**
* Workaround for https://bugs.openjdk.org/browse/JDK-8323659 regression, introduced in JDK-21.0.2.
*/
@Override
public boolean offer(E e, long timeout, TimeUnit unit) {
return super.offer(e);

Check warning on line 465 in server/src/main/java/org/opensearch/common/util/concurrent/OpenSearchExecutors.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/common/util/concurrent/OpenSearchExecutors.java#L465

Added line #L465 was not covered by tests
}

/**
* Workaround for https://bugs.openjdk.org/browse/JDK-8323659 regression, introduced in JDK-21.0.2.
*/
@Override
public boolean add(E e) {
return super.offer(e);

Check warning on line 473 in server/src/main/java/org/opensearch/common/util/concurrent/OpenSearchExecutors.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/common/util/concurrent/OpenSearchExecutors.java#L473

Added line #L473 was not covered by tests
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.lessThanOrEqualTo;

/**
* Tests for OpenSearchExecutors and its components like OpenSearchAbortPolicy.
Expand Down Expand Up @@ -279,6 +280,41 @@ public void testScaleDown() throws Exception {
terminate(pool);
}

/**
* The test case is adapted from https://bugs.openjdk.org/browse/JDK-8323659 reproducer.
*/
public void testScaleUpWithSpawningTask() throws Exception {
ThreadPoolExecutor pool = OpenSearchExecutors.newScaling(
getClass().getName() + "/" + getTestName(),
0,
1,
between(1, 100),
randomTimeUnit(),
OpenSearchExecutors.daemonThreadFactory("test"),
threadContext
);
assertThat("Min property", pool.getCorePoolSize(), equalTo(0));
assertThat("Max property", pool.getMaximumPoolSize(), equalTo(1));

final CountDownLatch latch = new CountDownLatch(10);
class TestTask implements Runnable {
@Override
public void run() {
latch.countDown();
if (latch.getCount() > 0) {
pool.execute(TestTask.this);
}
}
}
pool.execute(new TestTask());
latch.await();

assertThat("wrong pool size", pool.getPoolSize(), lessThanOrEqualTo(1));
assertThat("wrong active size", pool.getActiveCount(), lessThanOrEqualTo(1));

terminate(pool);
}

public void testRejectionMessageAndShuttingDownFlag() throws InterruptedException {
int pool = between(1, 10);
int queue = between(0, 100);
Expand Down

0 comments on commit 2be4c6c

Please sign in to comment.