File tree 3 files changed +22
-5
lines changed
test/java/oracle/r2dbc/impl
3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -56,9 +56,11 @@ private OracleR2dbcOptions() {}
56
56
* ...
57
57
* .build();
58
58
* </pre>
59
- * If this option is not configured, then Oracle R2DBC will use
60
- * {@code ForkJoinPool}'s
61
- * {@linkplain ForkJoinPool#commonPool() common pool} by default.
59
+ * If this option is not configured, then Oracle R2DBC will
60
+ * use the {@linkplain ForkJoinPool#commonPool() common ForkJoinPool} by
61
+ * default. However, if the common {@code ForkJoinPool} has a maximum pool
62
+ * size that is potentially zero, then a single-threaded {@code Executor} will
63
+ * be used by default.
62
64
*/
63
65
public static final Option <Executor > EXECUTOR ;
64
66
Original file line number Diff line number Diff line change 102
102
*/
103
103
final class OracleConnectionFactoryImpl implements ConnectionFactory {
104
104
105
+ /**
106
+ * <p>
107
+ * The default executor when {@link OracleR2dbcOptions#EXECUTOR} is not
108
+ * configured. It will use the common {@code ForkJoinPool}, unless it has
109
+ * a maximum pool size of 0. See:
110
+ * https://github.com/oracle/oracle-r2dbc/issues/129
111
+ * </p>
112
+ */
113
+ private static final Executor DEFAULT_EXECUTOR =
114
+ "0" .equals (System .getProperty (
115
+ "java.util.concurrent.ForkJoinPool.common.parallelism" ))
116
+ ? new ForkJoinPool (1 )
117
+ : ForkJoinPool .commonPool ();
118
+
105
119
/** JDBC data source that this factory uses to open connections */
106
120
private final DataSource dataSource ;
107
121
@@ -200,7 +214,7 @@ final class OracleConnectionFactoryImpl implements ConnectionFactory {
200
214
201
215
Object executor = options .getValue (OracleR2dbcOptions .EXECUTOR );
202
216
if (executor == null ) {
203
- this .executor = ForkJoinPool . commonPool () ;
217
+ this .executor = DEFAULT_EXECUTOR ;
204
218
}
205
219
else if (executor instanceof Executor ) {
206
220
this .executor = (Executor ) executor ;
@@ -267,4 +281,5 @@ public Publisher<Connection> create() {
267
281
public ConnectionFactoryMetadata getMetadata () {
268
282
return () -> "Oracle Database" ;
269
283
}
284
+
270
285
}
Original file line number Diff line number Diff line change @@ -3222,7 +3222,7 @@ private void verifyConcurrentFetch(Connection connection) {
3222
3222
// Create many statements and execute them in parallel.
3223
3223
@ SuppressWarnings ({"unchecked" ,"rawtypes" })
3224
3224
Publisher <Long >[] publishers =
3225
- new Publisher [Runtime .getRuntime ().availableProcessors () * 4 ];
3225
+ new Publisher [Runtime .getRuntime ().availableProcessors () * 2 ];
3226
3226
3227
3227
for (int i = 0 ; i < publishers .length ; i ++) {
3228
3228
You can’t perform that action at this time.
0 commit comments