Skip to content

Commit

Permalink
Make sure NoUniqueBeanDefinitionException to be serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
perlun authored and snicoll committed Aug 27, 2023
1 parent ca14202 commit 1b409d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -21,6 +21,7 @@
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;

Expand Down Expand Up @@ -215,7 +216,7 @@ public boolean isEager() {
*/
@Nullable
public Object resolveNotUnique(ResolvableType type, Map<String, Object> matchingBeans) throws BeansException {
throw new NoUniqueBeanDefinitionException(type, matchingBeans.keySet());
throw new NoUniqueBeanDefinitionException(type, new HashSet<>( matchingBeans.keySet() ));
}

/**
Expand Down
Expand Up @@ -30,6 +30,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -1296,7 +1297,7 @@ else if (candidateNames.length > 1) {
return new NamedBeanHolder<>(candidateName, (T) beanInstance);
}
if (!nonUniqueAsNull) {
throw new NoUniqueBeanDefinitionException(requiredType, candidates.keySet());
throw new NoUniqueBeanDefinitionException(requiredType, new HashSet<>(candidates.keySet()));
}
}

Expand Down

0 comments on commit 1b409d5

Please sign in to comment.