Skip to content

Commit 26d4901

Browse files
Specifying unsupported provided options
1 parent f4e9c74 commit 26d4901

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,19 @@ Most options can have a value provided by a `Supplier` or `Publisher`.
220220
Oracle R2DBC requests the value of a `Option` from a `Supplier` or `Publisher`
221221
each time `ConnectionFactory.create()` is called to create a new `Connection`. This
222222
allows connections to be configured with values that change over time, such as a
223-
password that is periodically rotated.
223+
password that gets periodically rotated.
224224

225-
If an `Option` is configured as a `Supplier`, then Oracle R2DBC requests the
226-
value of that `Option` by invoking its `get()` method. If concurrent
225+
If a `Supplier` provides the value of an `Option`, then Oracle R2DBC requests
226+
the value by invoking `Supplier.get()` method. If the `get()` returns `null`,
227+
then no value is configured for the `Option`. If `get()` throws a
228+
`RuntimeException`, then it is set as the initial cause of an
229+
`R2dbcException` emitted by the `create()` `Publisher`. If concurrent
227230
access to a `ConnectionFactory` is possible, then the `Supplier` must have a
228231
thread safe `get()` method, as multiple threads may invoke
229-
`ConnectionFactory.create()` concurrently. If the `Supplier` returns `null`,
230-
then no value is configured for the `Option`. If the `Supplier` throws a
231-
`RuntimeException`, then it is set as the initial cause of an
232-
`R2dbcException` emitted by the `create()` `Publisher`.
232+
`ConnectionFactory.create()` concurrently.
233233

234-
If an `Option` is configured as a `Publisher`, then Oracle R2DBC requests the
235-
value of that `Option` by subscribing to the `Publisher` and signalling demand.
234+
If a `Publisher` provides the value of an `Option`, then Oracle R2DBC requests
235+
the value by subscribing to the `Publisher` and signalling demand.
236236
The first value emitted to `onNext` will be used as the value of the `Option`.
237237
If the `Publisher` emits `onComplete` before `onNext`, then no value is
238238
configured for the `Option`. If the `Publisher` emits `onError` before `onNext`,
@@ -247,7 +247,7 @@ The following example configures the `PASSWORD` option with a `Supplier`:
247247
Option<Supplier<CharSequence>> suppliedOption = OracleR2dbcOptions.supplied(PASSWORD);
248248

249249
// Supply a password
250-
Supplier<CharSequence> supplier = () -> getCurrentPassword();
250+
Supplier<CharSequence> supplier = () -> getPassword();
251251

252252
// Configure the builder
253253
optionsBuilder.option(suppliedOption, supplier);
@@ -276,7 +276,7 @@ Note that the following code would compile, but fails at runtime with a
276276
`ClassCastException`:
277277
```java
278278
void configurePassword(ConnectionFactoryOptions.Builder optionsBuilder) {
279-
Publisher<CharSequence> publisher = Mono.fromSupplier(() -> getPassword()));
279+
Publisher<CharSequence> publisher = Mono.fromSupplier(() -> getPassword());
280280
// Doesn't work. Throws ClassCastException at runtime:
281281
optionsBuilder.option(PASSWORD, PASSWORD.cast(publisher));
282282
}
@@ -285,6 +285,14 @@ To avoid a `ClassCastException`, the generic type of an `Option` must match the
285285
actual type of the value passed to
286286
`ConnectionFactoryOptions.Builder.option(Option<T>, T)`.
287287

288+
Providing values with a `Supplier` or `Publisher` is not supported for a small
289+
set of options:
290+
- `DRIVER`
291+
- `PROTOCOL`
292+
293+
Providing values for these options would not be interoperable with
294+
`io.r2dbc.spi.ConnectionFactories` and `r2dbc-pool`.
295+
288296
#### Configuring an Oracle Net Descriptor
289297
The `oracle.r2dbc.OracleR2dbcOptions.DESCRIPTOR` option may be used to configure
290298
an Oracle Net Descriptor of the form ```(DESCRIPTION=...)```. If this option is

0 commit comments

Comments
 (0)