spring-projects/spring-framework · error · UnsupportedOperationException

Only supports includeNonSingletons=true by default

Error message

Only supports includeNonSingletons=true by default

What it means

Error "Only supports includeNonSingletons=true by default" thrown in spring-projects/spring-framework.

Source

Thrown at spring-beans/src/main/java/org/springframework/beans/factory/ObjectProvider.java:307

	default Stream<T> orderedStream(Predicate<Class<?>> customFilter) {
		return orderedStream(customFilter, true);
	}

	/**
	 * Return a custom-filtered {@link Stream} over all matching object instances,
	 * without specific ordering guarantees (but typically in registration order).
	 * @param customFilter a custom type filter for selecting beans among the raw
	 * bean type matches (or {@link #UNFILTERED} for all raw type matches without
	 * any default filtering)
	 * @param includeNonSingletons whether to include prototype or scoped beans too
	 * or just singletons (also applies to FactoryBeans)
	 * @since 6.2.5
	 * @see #stream(Predicate)
	 * @see #orderedStream(Predicate, boolean)
	 */
	default Stream<T> stream(Predicate<Class<?>> customFilter, boolean includeNonSingletons) {
		if (!includeNonSingletons) {
			throw new UnsupportedOperationException("Only supports includeNonSingletons=true by default");
		}
		return stream().filter(obj -> customFilter.test(obj.getClass()));
	}

	/**
	 * Return a custom-filtered {@link Stream} over all matching object instances,
	 * pre-ordered according to the factory's common order comparator.
	 * @param customFilter a custom type filter for selecting beans among the raw
	 * bean type matches (or {@link #UNFILTERED} for all raw type matches without
	 * any default filtering)
	 * @param includeNonSingletons whether to include prototype or scoped beans too
	 * or just singletons (also applies to FactoryBeans)
	 * @since 6.2.5
	 * @see #orderedStream()
	 * @see #stream(Predicate)
	 */
	default Stream<T> orderedStream(Predicate<Class<?>> customFilter, boolean includeNonSingletons) {
		if (!includeNonSingletons) {

View on GitHub (pinned to e8729d0438)

When it happens

Trigger: Thrown at spring-beans/src/main/java/org/springframework/beans/factory/ObjectProvider.java:307 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of spring-projects/spring-framework@e8729d0438 (2026-08-04). Data as JSON: /data/errors/675bece8560b9d06.json. Report an issue: GitHub.