Skip to content

Commit dd8c5a8

Browse files
Use concatMap when awaiting an error
1 parent a82b0c7 commit dd8c5a8

File tree

3 files changed

+32
-33
lines changed

3 files changed

+32
-33
lines changed

src/main/java/oracle/r2dbc/impl/OracleStatementImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,8 +1498,7 @@ private static void registerOutParameters(
14981498
Flux.from(bindFunction.apply(preparedStatement, discardQueue))
14991499
.thenMany(resultFunction.apply(preparedStatement)),
15001500
discardQueue ->
1501-
Flux.fromIterable(discardQueue)
1502-
.concatMapDelayError(Function.identity()))
1501+
Flux.concatDelayError(Flux.fromIterable(discardQueue)))
15031502
.doOnNext(result -> isResultEmitted.set(true))
15041503
.onErrorResume(R2dbcException.class, r2dbcException ->
15051504
Mono.just(OracleResultImpl.createErrorResult(r2dbcException)))

src/test/java/oracle/r2dbc/impl/OracleReadableImplTest.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void testGetByIndex() {
6666
Flux.from(connection.createStatement(
6767
"SELECT x, y FROM testGetByIndex")
6868
.execute())
69-
.flatMap(result ->
69+
.concatMap(result ->
7070
result.map((row, metadata) -> row.get(-1))));
7171

7272
// Expect IllegalArgumentException for an index greater than or equal
@@ -75,7 +75,7 @@ public void testGetByIndex() {
7575
Flux.from(connection.createStatement(
7676
"SELECT x, y FROM testGetByIndex")
7777
.execute())
78-
.flatMap(result ->
78+
.concatMap(result ->
7979
result.map((row, metadata) -> row.get(2))));
8080

8181
// Expect valid indexes to return the INSERTed values
@@ -134,45 +134,45 @@ public void testGetByName() {
134134
Flux.from(connection.createStatement(
135135
"SELECT x, y FROM testGetByName")
136136
.execute())
137-
.flatMap(result ->
137+
.concatMap(result ->
138138
result.map((row, metadata) -> row.get(null))));
139139

140140
// Expect IllegalArgumentException for unmatched names
141141
awaitError(IllegalArgumentException.class,
142142
Flux.from(connection.createStatement(
143143
"SELECT x, y FROM testGetByName")
144144
.execute())
145-
.flatMap(result ->
145+
.concatMap(result ->
146146
result.map((row, metadata) -> row.get("z"))));
147147
awaitError(IllegalArgumentException.class,
148148
Flux.from(connection.createStatement(
149149
"SELECT x, y FROM testGetByName")
150150
.execute())
151-
.flatMap(result ->
151+
.concatMap(result ->
152152
result.map((row, metadata) -> row.get("xx"))));
153153
awaitError(IllegalArgumentException.class,
154154
Flux.from(connection.createStatement(
155155
"SELECT x, y FROM testGetByName")
156156
.execute())
157-
.flatMap(result ->
157+
.concatMap(result ->
158158
result.map((row, metadata) -> row.get("x "))));
159159
awaitError(IllegalArgumentException.class,
160160
Flux.from(connection.createStatement(
161161
"SELECT x, y FROM testGetByName")
162162
.execute())
163-
.flatMap(result ->
163+
.concatMap(result ->
164164
result.map((row, metadata) -> row.get(" x"))));
165165
awaitError(IllegalArgumentException.class,
166166
Flux.from(connection.createStatement(
167167
"SELECT x, y FROM testGetByName")
168168
.execute())
169-
.flatMap(result ->
169+
.concatMap(result ->
170170
result.map((row, metadata) -> row.get(" "))));
171171
awaitError(IllegalArgumentException.class,
172172
Flux.from(connection.createStatement(
173173
"SELECT x, y FROM testGetByName")
174174
.execute())
175-
.flatMap(result ->
175+
.concatMap(result ->
176176
result.map((row, metadata) -> row.get(""))));
177177

178178
// Expect valid names to return the INSERTed values
@@ -290,7 +290,7 @@ public void testGetByIndexAndType() {
290290
Flux.from(connection.createStatement(
291291
"SELECT x, y FROM testGetByIndexAndType")
292292
.execute())
293-
.flatMap(result ->
293+
.concatMap(result ->
294294
result.map((row, metadata) -> row.get(0, null))));
295295

296296
// Expect IllegalArgumentException for an unsupported type
@@ -299,7 +299,7 @@ class Unsupported {}
299299
Flux.from(connection.createStatement(
300300
"SELECT x, y FROM testGetByIndexAndType")
301301
.execute())
302-
.flatMap(result ->
302+
.concatMap(result ->
303303
result.map((row, metadata) ->
304304
row.get(0, Unsupported.class))));
305305

@@ -308,7 +308,7 @@ class Unsupported {}
308308
Flux.from(connection.createStatement(
309309
"SELECT x, y FROM testGetByIndexAndType")
310310
.execute())
311-
.flatMap(result ->
311+
.concatMap(result ->
312312
result.map((row, metadata) -> row.get(-1, Integer.class))));
313313

314314
// Expect IllegalArgumentException for an index greater than or equal
@@ -317,7 +317,7 @@ class Unsupported {}
317317
Flux.from(connection.createStatement(
318318
"SELECT x, y FROM testGetByIndexAndType")
319319
.execute())
320-
.flatMap(result ->
320+
.concatMap(result ->
321321
result.map((row, metadata) -> row.get(2, Integer.class))));
322322

323323
// Expect valid indexes to return the INSERTed values
@@ -379,7 +379,7 @@ public void testGetByNameAndType() {
379379
Flux.from(connection.createStatement(
380380
"SELECT x, y FROM testGetByNameAndType")
381381
.execute())
382-
.flatMap(result ->
382+
.concatMap(result ->
383383
result.map((row, metadata) -> row.get("x", null))));
384384

385385
// Expect IllegalArgumentException for an unsupported type
@@ -388,7 +388,7 @@ class Unsupported {}
388388
Flux.from(connection.createStatement(
389389
"SELECT x, y FROM testGetByNameAndType")
390390
.execute())
391-
.flatMap(result ->
391+
.concatMap(result ->
392392
result.map((row, metadata) ->
393393
row.get("x", Unsupported.class))));
394394

@@ -397,45 +397,45 @@ class Unsupported {}
397397
Flux.from(connection.createStatement(
398398
"SELECT x, y FROM testGetByNameAndType")
399399
.execute())
400-
.flatMap(result ->
400+
.concatMap(result ->
401401
result.map((row, metadata) -> row.get(null, Integer.class))));
402402

403403
// Expect IllegalArgumentException for unmatched names
404404
awaitError(IllegalArgumentException.class,
405405
Flux.from(connection.createStatement(
406406
"SELECT x, y FROM testGetByNameAndType")
407407
.execute())
408-
.flatMap(result ->
408+
.concatMap(result ->
409409
result.map((row, metadata) -> row.get("z", Integer.class))));
410410
awaitError(IllegalArgumentException.class,
411411
Flux.from(connection.createStatement(
412412
"SELECT x, y FROM testGetByNameAndType")
413413
.execute())
414-
.flatMap(result ->
414+
.concatMap(result ->
415415
result.map((row, metadata) -> row.get("xx", Integer.class))));
416416
awaitError(IllegalArgumentException.class,
417417
Flux.from(connection.createStatement(
418418
"SELECT x, y FROM testGetByNameAndType")
419419
.execute())
420-
.flatMap(result ->
420+
.concatMap(result ->
421421
result.map((row, metadata) -> row.get("x ", Integer.class))));
422422
awaitError(IllegalArgumentException.class,
423423
Flux.from(connection.createStatement(
424424
"SELECT x, y FROM testGetByNameAndType")
425425
.execute())
426-
.flatMap(result ->
426+
.concatMap(result ->
427427
result.map((row, metadata) -> row.get(" x", Integer.class))));
428428
awaitError(IllegalArgumentException.class,
429429
Flux.from(connection.createStatement(
430430
"SELECT x, y FROM testGetByNameAndType")
431431
.execute())
432-
.flatMap(result ->
432+
.concatMap(result ->
433433
result.map((row, metadata) -> row.get(" ", Integer.class))));
434434
awaitError(IllegalArgumentException.class,
435435
Flux.from(connection.createStatement(
436436
"SELECT x, y FROM testGetByNameAndType")
437437
.execute())
438-
.flatMap(result ->
438+
.concatMap(result ->
439439
result.map((row, metadata) -> row.get("", Integer.class))));
440440

441441
// Expect valid names to return the INSERTed values

src/test/java/oracle/r2dbc/impl/OracleRowMetadataImplTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void testGetColumnMetadataByIndex() {
8484
Flux.from(connection.createStatement(
8585
"SELECT x, y FROM testGetColumnMetadataByIndex")
8686
.execute())
87-
.flatMap(result ->
87+
.concatMap(result ->
8888
result.map((row, metadata) ->
8989
metadata.getColumnMetadata(-1).getPrecision())));
9090

@@ -94,7 +94,7 @@ public void testGetColumnMetadataByIndex() {
9494
Flux.from(connection.createStatement(
9595
"SELECT x, y FROM testGetColumnMetadataByIndex")
9696
.execute())
97-
.flatMap(result ->
97+
.concatMap(result ->
9898
result.map((row, metadata) ->
9999
metadata.getColumnMetadata(2).getPrecision())));
100100

@@ -165,7 +165,7 @@ public void testGetColumnMetadataByName() {
165165
Flux.from(connection.createStatement(
166166
"SELECT x, y FROM testGetColumnMetadataByName")
167167
.execute())
168-
.flatMap(result ->
168+
.concatMap(result ->
169169
result.map((row, metadata) -> metadata.getColumnMetadata(null))
170170
));
171171

@@ -174,42 +174,42 @@ public void testGetColumnMetadataByName() {
174174
Flux.from(connection.createStatement(
175175
"SELECT x, y FROM testGetColumnMetadataByName")
176176
.execute())
177-
.flatMap(result ->
177+
.concatMap(result ->
178178
result.map((row, metadata) -> metadata.getColumnMetadata("z"))
179179
));
180180
awaitError(NoSuchElementException.class,
181181
Flux.from(connection.createStatement(
182182
"SELECT x, y FROM testGetColumnMetadataByName")
183183
.execute())
184-
.flatMap(result ->
184+
.concatMap(result ->
185185
result.map((row, metadata) -> metadata.getColumnMetadata("xx"))
186186
));
187187
awaitError(NoSuchElementException.class,
188188
Flux.from(connection.createStatement(
189189
"SELECT x, y FROM testGetColumnMetadataByName")
190190
.execute())
191-
.flatMap(result ->
191+
.concatMap(result ->
192192
result.map((row, metadata) -> metadata.getColumnMetadata("x "))
193193
));
194194
awaitError(NoSuchElementException.class,
195195
Flux.from(connection.createStatement(
196196
"SELECT x, y FROM testGetColumnMetadataByName")
197197
.execute())
198-
.flatMap(result ->
198+
.concatMap(result ->
199199
result.map((row, metadata) -> metadata.getColumnMetadata(" x"))
200200
));
201201
awaitError(NoSuchElementException.class,
202202
Flux.from(connection.createStatement(
203203
"SELECT x, y FROM testGetColumnMetadataByName")
204204
.execute())
205-
.flatMap(result ->
205+
.concatMap(result ->
206206
result.map((row, metadata) -> metadata.getColumnMetadata(" "))
207207
));
208208
awaitError(NoSuchElementException.class,
209209
Flux.from(connection.createStatement(
210210
"SELECT x, y FROM testGetColumnMetadataByName")
211211
.execute())
212-
.flatMap(result ->
212+
.concatMap(result ->
213213
result.map((row, metadata) -> metadata.getColumnMetadata(""))
214214
));
215215

0 commit comments

Comments
 (0)