Skip to content

Commit 6798600

Browse files
committed
Merge branch '4.11.x' into 4.x
2 parents 390a01c + 0d97dfd commit 6798600

File tree

5 files changed

+34
-19
lines changed

5 files changed

+34
-19
lines changed

changelog/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
- [improvement] JAVA-2935: Make GetEntity and SetEntity methods resilient to incomplete data
88
- [improvement] JAVA-2944: Upgrade MicroProfile Metrics to 3.0
99

10-
### 4.11.2 (in progress)
10+
### 4.11.2
1111

12+
- [bug] JAVA-2932: Make DefaultDriverConfigLoader.close() resilient to terminated executors
1213
- [bug] JAVA-2945: Reinstate InternalDriverContext.getNodeFilter method
1314
- [bug] JAVA-2947: Release buffer after decoding multi-slice frame
1415
- [bug] JAVA-2946: Make MapperResultProducerService instances be located with user-provided class loader

core/src/main/java/com/datastax/oss/driver/api/core/config/DriverConfigLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ static DriverConfigLoader compose(
376376
boolean supportsReloading();
377377

378378
/**
379-
* Called when the cluster closes. This is a good time to release any external resource, for
379+
* Called when the session closes. This is a good time to release any external resource, for
380380
* example cancel a scheduled reloading task.
381381
*/
382382
@Override

core/src/main/java/com/datastax/oss/driver/internal/core/config/typesafe/DefaultDriverConfigLoader.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.time.Duration;
4040
import java.util.concurrent.CompletableFuture;
4141
import java.util.concurrent.CompletionStage;
42+
import java.util.concurrent.RejectedExecutionException;
4243
import java.util.concurrent.TimeUnit;
4344
import java.util.function.Supplier;
4445
import net.jcip.annotations.ThreadSafe;
@@ -235,8 +236,14 @@ public Supplier<Config> getConfigSupplier() {
235236
@Override
236237
public void close() {
237238
SingleThreaded singleThreaded = this.singleThreaded;
238-
if (singleThreaded != null) {
239-
RunOrSchedule.on(singleThreaded.adminExecutor, singleThreaded::close);
239+
if (singleThreaded != null && !singleThreaded.adminExecutor.terminationFuture().isDone()) {
240+
try {
241+
RunOrSchedule.on(singleThreaded.adminExecutor, singleThreaded::close);
242+
} catch (RejectedExecutionException e) {
243+
// Checking the future is racy, there is still a tiny window that could get us here.
244+
// We can safely ignore this error because, if the execution is rejected, the periodic
245+
// reload task, if any, has been already cancelled.
246+
}
240247
}
241248
}
242249

core/src/test/java/com/datastax/oss/driver/internal/core/util/concurrent/ScheduledTaskCapturingEventLoop.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
@SuppressWarnings("FunctionalInterfaceClash") // does not matter for test code
4848
public class ScheduledTaskCapturingEventLoop extends DefaultEventLoop {
4949

50-
private final BlockingQueue<CapturedTask> capturedTasks = new ArrayBlockingQueue<>(100);
50+
private final BlockingQueue<CapturedTask<?>> capturedTasks = new ArrayBlockingQueue<>(100);
5151

5252
public ScheduledTaskCapturingEventLoop(EventLoopGroup parent) {
5353
super(parent);

integration-tests/src/test/java/com/datastax/oss/driver/mapper/SelectCustomWhereClauseIT.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.datastax.oss.driver.mapper;
1717

1818
import static com.datastax.oss.driver.assertions.Assertions.assertThat;
19+
import static org.awaitility.Awaitility.await;
1920
import static org.junit.Assume.assumeFalse;
2021

2122
import com.datastax.oss.driver.api.core.CqlIdentifier;
@@ -36,8 +37,8 @@
3637
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
3738
import com.datastax.oss.driver.categories.ParallelizableTests;
3839
import com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures;
40+
import java.time.Duration;
3941
import java.util.concurrent.CompletionStage;
40-
import org.junit.Before;
4142
import org.junit.BeforeClass;
4243
import org.junit.ClassRule;
4344
import org.junit.Test;
@@ -73,29 +74,35 @@ public static void setup() {
7374
InventoryMapper inventoryMapper =
7475
new SelectCustomWhereClauseIT_InventoryMapperBuilder(session).build();
7576
dao = inventoryMapper.productDao(SESSION_RULE.keyspace());
76-
}
77-
78-
@Before
79-
public void insertData() {
8077
dao.save(FLAMETHROWER);
8178
dao.save(MP3_DOWNLOAD);
8279
}
8380

8481
@Test
8582
public void should_select_with_custom_clause() {
86-
PagingIterable<Product> products = dao.findByDescription("%mp3%");
87-
assertThat(products.one()).isEqualTo(MP3_DOWNLOAD);
88-
assertThat(products.iterator()).isExhausted();
83+
await()
84+
.atMost(Duration.ofMinutes(1))
85+
.untilAsserted(
86+
() -> {
87+
PagingIterable<Product> products = dao.findByDescription("%mp3%");
88+
assertThat(products.one()).isEqualTo(MP3_DOWNLOAD);
89+
assertThat(products.iterator()).isExhausted();
90+
});
8991
}
9092

9193
@Test
9294
public void should_select_with_custom_clause_asynchronously() {
93-
MappedAsyncPagingIterable<Product> iterable =
94-
CompletableFutures.getUninterruptibly(
95-
dao.findByDescriptionAsync("%mp3%").toCompletableFuture());
96-
assertThat(iterable.one()).isEqualTo(MP3_DOWNLOAD);
97-
assertThat(iterable.currentPage().iterator()).isExhausted();
98-
assertThat(iterable.hasMorePages()).isFalse();
95+
await()
96+
.atMost(Duration.ofMinutes(1))
97+
.untilAsserted(
98+
() -> {
99+
MappedAsyncPagingIterable<Product> iterable =
100+
CompletableFutures.getUninterruptibly(
101+
dao.findByDescriptionAsync("%mp3%").toCompletableFuture());
102+
assertThat(iterable.one()).isEqualTo(MP3_DOWNLOAD);
103+
assertThat(iterable.currentPage().iterator()).isExhausted();
104+
assertThat(iterable.hasMorePages()).isFalse();
105+
});
99106
}
100107

101108
@Mapper

0 commit comments

Comments
 (0)