diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleReactiveMongoRepository.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleReactiveMongoRepository.java index 3a99ef5a8..ff412f9be 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleReactiveMongoRepository.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleReactiveMongoRepository.java @@ -45,6 +45,7 @@ import org.springframework.util.Assert; * @author Mark Paluch * @author Oliver Gierke * @author Christoph Strobl + * @author Ruben J Garcia * @since 2.0 */ @RequiredArgsConstructor @@ -97,7 +98,7 @@ public class SimpleReactiveMongoRepository implement return Mono.error(new IncorrectResultSizeDataAccessException(1)); } return Mono.just(vals.iterator().next()); - }).single(); + }).next(); } /* diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/SimpleReactiveMongoRepositoryTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/SimpleReactiveMongoRepositoryTests.java index 40685fddd..f01f53a33 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/SimpleReactiveMongoRepositoryTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/SimpleReactiveMongoRepositoryTests.java @@ -54,6 +54,7 @@ import org.springframework.util.ClassUtils; * * @author Mark Paluch * @author Christoph Strobl + * @author Ruben J Garcia */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:reactive-infrastructure.xml") @@ -441,6 +442,14 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware, StepVerifier.create(repository.findOne(example)).expectError(IncorrectResultSizeDataAccessException.class); } + @Test // DATAMONGO-1907 + public void existsByExampleShouldReturnNonExistingWithoutThrowException() { + + Example example = Example.of(new ReactivePerson("foo", "bar", -1)); + + StepVerifier.create(repository.findOne(example)).verifyComplete(); + } + interface ReactivePersonRepostitory extends ReactiveMongoRepository { Flux findByLastname(String lastname);