Skip to content

RepositoryRestHandlerMapping 2 arg constructor broken [DATAREST-994] #1358

Closed
@spring-projects-issues

Description

@spring-projects-issues

Colin Steele opened DATAREST-994 and commented

RepositoryRestHandlerMapping constructor change breaks backwards compatibility after crossorigin was added. RepositoryCorsConfigurationAccessor constructor arg "repositories" is marked @NonNull causing the legacy 2 arg constructor for the outer class to fail lombok validation. This was probably an oversight as "repositories" param desc still lists it as optional. Cross posting for springfox-data-rest compatibility issue.

RepositoryRestHandlerMapping.java

	public RepositoryRestHandlerMapping(ResourceMappings mappings, RepositoryRestConfiguration config) {
		this(mappings, config, null);
	}

	/**
	 * Creates a new {@link RepositoryRestHandlerMapping} for the given {@link ResourceMappings}
	 * {@link RepositoryRestConfiguration} and {@link Repositories}.
	 *
	 * @param mappings must not be {@literal null}.
	 * @param config must not be {@literal null}.
	 * @param repositories can be {@literal null} if {@link CrossOrigin} resolution is not required.
	 */
	public RepositoryRestHandlerMapping(ResourceMappings mappings, RepositoryRestConfiguration config,
			Repositories repositories) {

		super(config);

		Assert.notNull(mappings, "ResourceMappings must not be null!");
		Assert.notNull(config, "RepositoryRestConfiguration must not be null!");

		this.mappings = mappings;
		this.configuration = config;
		this.repositories = repositories;
		this.corsConfigurationAccessor = new RepositoryCorsConfigurationAccessor(mappings, repositories,
				NoOpStringValueResolver.INSTANCE);

Commit msg

DATAREST-573 - Polishing. …
Removed RepositoryRestConfiguration.addCorsMapping(…) as we currently don't have any other shortcut methods for configuration like this.

Tweaked the setup of (now Repository)CorsConfigurationAccessor to be created earlier so that we avoid recreation for every lookup. Introduced a NoOpStringValueResolver to be used by default so that we don't need to deal with the case of the resolver being null at the end of the call chain. Replaced constructor of RepositoryCorsConfigurationAccessor with corresponding Lombok annotation.

Updated reference documentation accordingly.

Original pull request: #233.
olivergierke committed on Oct 28, 2016
40bb8e8


Affects: 3.0 M1 (Kay), 3.0 M2 (Kay), 2.6 GA (Ingalls), 2.6.1 (Ingalls SR1)

Referenced from: pull request #257, and commits 3e5f4bd, e580c04, 3715b1c, d622ff0, db770fb, ea482e0, e94ba4a

Backported to: 2.6.1 (Ingalls SR1)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions