File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
spring-r2dbc/src/main/java/org/springframework/r2dbc/core Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -59,18 +59,11 @@ class DefaultFetchSpec<T> implements FetchSpec<T> {
59
59
60
60
@ Override
61
61
public Mono <T > one () {
62
- return all ().buffer (2 )
63
- .flatMap (list -> {
64
- if (list .isEmpty ()) {
65
- return Mono .empty ();
66
- }
67
- if (list .size () > 1 ) {
68
- return Mono .error (new IncorrectResultSizeDataAccessException (
69
- String .format ("Query [%s] returned non unique result." , this .resultFunction .getSql ()),
70
- 1 ));
71
- }
72
- return Mono .just (list .get (0 ));
73
- }).next ();
62
+ return all ().singleOrEmpty ()
63
+ .onErrorMap (IndexOutOfBoundsException .class , ex -> {
64
+ String message = String .format ("Query [%s] returned non unique result." , this .resultFunction .getSql ());
65
+ return new IncorrectResultSizeDataAccessException (message , 1 );
66
+ });
74
67
}
75
68
76
69
@ Override
You can’t perform that action at this time.
0 commit comments