Skip to content

Commit 40d69a9

Browse files
Rephrasing supplied options doc
1 parent 1de4f5b commit 40d69a9

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

README.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -217,27 +217,27 @@ are declared in the
217217
#### Support for Supplier and Publisher as Option Values
218218
Most options can have a value provided by a `Supplier` or `Publisher`.
219219

220-
Oracle R2DBC requests the value of a `Option` from a `Supplier` or `Publisher`
221-
each time `ConnectionFactory.create()` is called to create a new `Connection`. This
222-
allows connections to be configured with values that change over time, such as a
223-
password that gets periodically rotated.
220+
Oracle R2DBC requests the value of an `Option` from a `Supplier` or `Publisher`
221+
each time the `Publisher` returned by `ConnectionFactory.create()` creates a new
222+
`Connection`. Each `Connection` can then be configured with values that change
223+
over time, such as a password which is periodically rotated.
224224

225225
If a `Supplier` provides the value of an `Option`, then Oracle R2DBC requests
226226
the value by invoking `Supplier.get()`. If `get()` returns `null`,
227227
then no value is configured for the `Option`. If `get()` throws a
228228
`RuntimeException`, then it is set as the initial cause of an
229-
`R2dbcException` emitted by the `create()` `Publisher`. If concurrent
230-
access to a `ConnectionFactory` is possible, then the `Supplier` must have a
231-
thread safe `get()` method, as multiple threads may invoke
232-
`ConnectionFactory.create()` concurrently.
229+
`R2dbcException` emitted by the `Publisher` returned by
230+
`ConnectionFactory.create()`. The `Supplier` must have a thread safe `get()`
231+
method, as multiple subscribers may request connections concurrently.
233232

234233
If a `Publisher` provides the value of an `Option`, then Oracle R2DBC requests
235234
the value by subscribing to the `Publisher` and signalling demand.
236235
The first value emitted to `onNext` will be used as the value of the `Option`.
237236
If the `Publisher` emits `onComplete` before `onNext`, then no value is
238237
configured for the `Option`. If the `Publisher` emits `onError` before `onNext`,
239-
then the `Throwable` is set as the initial cause of an `R2dbcException` emitted
240-
by the `create()` `Publisher`.
238+
then the `Throwable` is set as the initial cause of an
239+
`R2dbcException` emitted by the `Publisher` returned by
240+
`ConnectionFactory.create()`.
241241

242242
The following example configures the `PASSWORD` option with a `Supplier`:
243243
```java
@@ -253,7 +253,7 @@ The following example configures the `PASSWORD` option with a `Supplier`:
253253
optionsBuilder.option(suppliedOption, supplier);
254254
}
255255
```
256-
A similar and more concise example configures `TLS_WALLET_PASSWORD` as a `Publisher`
256+
A more concise example configures `TLS_WALLET_PASSWORD` as a `Publisher`
257257
```java
258258
void configurePassword(ConnectionFactoryOptions.Builder optionsBuilder) {
259259
optionsBuilder.option(
@@ -263,13 +263,12 @@ A similar and more concise example configures `TLS_WALLET_PASSWORD` as a `Publis
263263
```
264264
These examples use the `supplied(Option)` and `published(Option)` methods
265265
declared by `oracle.r2dbc.OracleR2dbcOptions`. These methods cast an `Option<T>`
266-
to `Option<Supplier<T>>` or `Option<Publisher<T>>`, respectively. Casting the
267-
`Option` is required for
268-
`ConnectionFactoryOptions.Builder.option(Option<T>, T)` to compile and not throw
269-
a `ClassCastException` at runtime.
270-
271-
It is not strictly necessary to use the `supplied(Option)` or `published(Option)` methods when
272-
casting the `Option`. These methods are offered only for code readability and
266+
to `Option<Supplier<T>>` and `Option<Publisher<T>>`, respectively. It is
267+
necessary to cast the generic type of the `Option` when calling
268+
`ConnectionFactoryOptions.Builder.option(Option<T>, T)` in order for the call to
269+
compile and not throw a `ClassCastException` at runtime. It is not strictly
270+
required that `supplied(Option)` or `published(Option)` be used to cast the
271+
`Option`. These methods are only meant to offer code readability and
273272
convenience.
274273

275274
Note that the following code would compile, but fails at runtime with a
@@ -285,8 +284,8 @@ To avoid a `ClassCastException`, the generic type of an `Option` must match the
285284
actual type of the value passed to
286285
`ConnectionFactoryOptions.Builder.option(Option<T>, T)`.
287286

288-
Providing values with a `Supplier` or `Publisher` is not supported for a small
289-
set of options:
287+
For a small set of options, providing values with a `Supplier` or `Publisher`
288+
is not supported:
290289
- `DRIVER`
291290
- `PROTOCOL`
292291

0 commit comments

Comments
 (0)