Skip to content

Commit 13e5e39

Browse files
committed
Address review comments.
1 parent d1a1864 commit 13e5e39

6 files changed

+15
-12
lines changed

src/main/java/org/springframework/data/repository/core/support/FragmentNotImplementedException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
package org.springframework.data.repository.core.support;
1717

1818
/**
19-
* Exception thrown when a fragment remains with without an implementation during repository creation.
19+
* Exception thrown during repository creation or repository method invocation when invoking a repository method on a
20+
* fragment without an implementation.
2021
*
2122
* @author Mark Paluch
2223
* @since 2.5
2324
*/
2425
@SuppressWarnings("serial")
25-
public class FragmentNotImplementedException extends RepositoryCreationException {
26+
public class FragmentNotImplementedException extends RepositoryException {
2627

2728
private final RepositoryFragment<?> fragment;
2829

src/main/java/org/springframework/data/repository/core/support/MissingFragmentException.java renamed to src/main/java/org/springframework/data/repository/core/support/IncompleteRepositoryCompositionException.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,22 @@
1616
package org.springframework.data.repository.core.support;
1717

1818
/**
19-
* Exception thrown during repository creation when a fragment implementation is missing.
19+
* Exception thrown during repository creation or repository method invocation when a the repository has custom methods
20+
* that are not backed by a fragment or if no fragment could be found for a repository method invocation.
2021
*
2122
* @author Mark Paluch
2223
* @since 2.5
2324
*/
2425
@SuppressWarnings("serial")
25-
public class MissingFragmentException extends RepositoryCreationException {
26+
public class IncompleteRepositoryCompositionException extends RepositoryException {
2627

2728
/**
28-
* Constructor for MissingFragmentException.
29+
* Constructor for IncompleteRepositoryCompositionException.
2930
*
3031
* @param msg the detail message.
3132
* @param repositoryInterface the repository interface.
3233
*/
33-
public MissingFragmentException(String msg, Class<?> repositoryInterface) {
34+
public IncompleteRepositoryCompositionException(String msg, Class<?> repositoryInterface) {
3435
super(msg, repositoryInterface);
3536
}
3637
}

src/main/java/org/springframework/data/repository/core/support/RepositoryComposition.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,8 @@ private RepositoryFragment<?> findImplementationFragment(Method key, Class<?> re
536536
return stream().filter(it -> it.hasMethod(key)) //
537537
.filter(it -> it.getImplementation().isPresent()) //
538538
.findFirst()
539-
.orElseThrow(() -> new MissingFragmentException(String.format("No fragment found for method %s", key),
539+
.orElseThrow(() -> new IncompleteRepositoryCompositionException(
540+
String.format("No fragment found for method %s", key),
540541
repositoryInterface));
541542
}
542543

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
import org.springframework.dao.InvalidDataAccessApiUsageException;
1919

2020
/**
21-
* Exception thrown when the repository instance cannot be created.
21+
* Exception thrown in the context of repository creation/invocation.
2222
*
2323
* @author Mark Paluch
2424
* @since 2.5
2525
*/
2626
@SuppressWarnings("serial")
27-
public class RepositoryCreationException extends InvalidDataAccessApiUsageException {
27+
public class RepositoryException extends InvalidDataAccessApiUsageException {
2828

2929
private final Class<?> repositoryInterface;
3030

@@ -34,7 +34,7 @@ public class RepositoryCreationException extends InvalidDataAccessApiUsageExcept
3434
* @param msg the detail message.
3535
* @param repositoryInterface the repository interface.
3636
*/
37-
public RepositoryCreationException(String msg, Class<?> repositoryInterface) {
37+
public RepositoryException(String msg, Class<?> repositoryInterface) {
3838
super(msg);
3939
this.repositoryInterface = repositoryInterface;
4040
}

src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ public static void validate(RepositoryComposition composition, Class<?> source,
758758

759759
if (composition.isEmpty()) {
760760

761-
throw new MissingFragmentException(
761+
throw new IncompleteRepositoryCompositionException(
762762
String.format("You have custom methods in %s but have not provided a custom implementation!",
763763
org.springframework.util.ClassUtils.getQualifiedName(repositoryInterface)),
764764
repositoryInterface);

src/main/java/org/springframework/data/repository/core/support/UnsupportedFragmentException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* @since 2.5
2424
*/
2525
@SuppressWarnings("serial")
26-
public class UnsupportedFragmentException extends RepositoryCreationException {
26+
public class UnsupportedFragmentException extends RepositoryException {
2727

2828
private final Class<?> fragmentInterface;
2929

0 commit comments

Comments
 (0)