Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation of URI segments and request parameters into aggregates broken [DATACMNS-1743] #2164

Closed
spring-projects-issues opened this issue Jun 12, 2020 · 16 comments
Assignees
Labels
in: core type: regression

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Jun 12, 2020

Craig opened DATACMNS-1743 and commented

I have a controller class (annotated with @RepositoryRestController) with this method:

@ResponseBody
 @RequestMapping(method=RequestMethod.GET,value="/domainWords/search/findByDomainSetWithLocale")
 public CollectionModel<EntityModel<DomainWord>> findByDomainSetAndLocale(final @NonNull @RequestParam("domainSet") DomainSet domainSet, final @NonNull @RequestParam("locale") Locale locale)

 

DomainSet's repository is:

@Repository
public interface DomainSetRepository extends org.springframework.data.repository.Repository<DomainSet, Long>

 

The test is to request

/api/domainWords/search/findByDomainSetWithLocale?domainSet=1&locale=es_ES

With Spring Data Neumann RELEASE, that works great.

With Spring Data Neumann SR1, it fails.

With Spring Data Neumann SR1 forcing spring-data-commons to version 2.3.0.RELEASE, it fails.

Therefore, this issue is a regression in spring-data-commons 2.3.1.RELEASE. So the problem is caused somewhere in this commit range: 2.3.0.RELEASE...2.3.1.RELEASE

 

When it fails, here's the error:

Resolved [org.springframework.web.method.annotation.MethodArgumentConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'com.isobar.mindsight.domain.DomainSet'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'com.isobar.mindsight.domain.DomainSet': no matching editors or conversion strategy found]

Affects: 2.2.8 (Moore SR8), 2.3.1 (Neumann SR1)

Issue Links:

  • DATACMNS-1734 Delay Repositories initialization in DomainClassConverter

Backported to: 2.3.2 (Neumann SR2), 2.2.9 (Moore SR9)

2 votes, 9 watchers

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jun 15, 2020

Željko Tomić commented

I have same issue. As I can see, it is introduced with changes in DomainClassConverter for DATACMNS-1734. DomainClassConverter has now Lazy initialization and ToEntityConverter and ToIdConverter converters are not registered to ConversionService at startup. If I force initialization in DomainClassConverter#setApplicationContext with this.repositories.get(); all is working as before.

 

As mentioned on Gitter also, here is minimal SB example to reproduce: https://github.com/ztomic/data-jpa-example

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jun 15, 2020

Benjamin M commented

I have the same issue after updating to Spring Boot 2.2.8. After downgrading some dependencies to their Spring Boot 2.2.7 counterpart, I figured out that Spring Data Moore SR7 worked fine, and Spring Data Moore SR8 causes this issue.

Craig can you add Spring Data Moore SR8 to the affected versions of this issue?

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jun 15, 2020

Oliver Drotbohm commented

That's done. I have a fix locally coming this evening

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jun 15, 2020

Oliver Drotbohm commented

Snapshot builds for all declared fix versions available in a bit. I've also created a Spring Data example to verify the fix working but wouldn't mind if you folks gave the snapshots a spin.

Thanks for your patience and sorry for the inconvenience

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jun 16, 2020

Željko Tomić commented

I have just tried with Neumann-BUILD-SNAPSHOT and Spring Boot 2.3.1 and it is working OK. Oliver Drotbohm When should Neumann-SR2 be released?

<spring-data-releasetrain.version>Neumann-BUILD-SNAPSHOT</spring-data-releasetrain.version>

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jun 16, 2020

Željko Tomić commented

Oliver Drotbohm

I have done one more test, it is not OK. Before changes in DomainClassConverter (in Neumann-RELEASE) when reading non existing entity (e.g. with id 0) corresponding controller method argument was null, now exception is thrown:

 

2020-06-16 08:09:28.478 ERROR 27408 --- [io-28888-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: argument type mismatch
Controller [com.example.jpa.DataJpaExampleApplication$DemoController]
Method [public com.example.jpa.DataJpaExampleApplication$MyEntity com.example.jpa.DataJpaExampleApplication$DemoController.get(com.example.jpa.DataJpaExampleApplication$MyEntity)] with argument values:
 [0] [type=java.lang.String] [value=0] ] with root causejava.lang.IllegalArgumentException: argument type mismatch

I have updated my minimal SB example (https://github.com/ztomic/data-jpa-example) to reproduce, you can simple run it and you'll get exception when starting

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jun 16, 2020

Oliver Drotbohm commented

Great feedback, I'll have a look

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jun 16, 2020

Željko Tomić commented

Thanks

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jun 16, 2020

Oliver Drotbohm commented

Fresh snapshots available in a minute. We – for some weird – reason fell back to the original source object (i.e. the raw String) if the aggregate lookup failed which is of course nonsense. Thanks for another round of testing!

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jun 16, 2020

Željko Tomić commented

No problems! Retested with minimal example and now is working as expected. Maybe it might be worth to mention this issue with Neumann.SR1 somewhere to make it easier for users to see until Neumann.SR2 and Spring Boot 2.3.2 are released

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jul 25, 2020

yukihane commented

Will this bug not be fixed on 2.1.x ?

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jul 25, 2020

Oliver Drotbohm commented

2.1.x was never affected

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Aug 1, 2020

yukihane commented

Hi. Here is my testcase.

'mvn clean test' result:

Spring Boot Version Test Result
2.1.14 pass
2.1.15 fail
2.1.16 fail
2.2.7 pass
2.2.8 fail
2.2.9 pass
2.3.0 pass
2.3.1 fail
2.3.2 pass

It seems that this issue also affects version 2.1.x and has not been fixed

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Aug 1, 2020

yukihane commented

Sorry, I missed attaching testcase.
https://github.com/yukihane/testcase-DATACMNS-1743

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Oct 11, 2020

derTobsch commented

Oliver Drotbohm 2.1.x was/is affected by this bug. You can have a look at the "urlaubsverwaltung" on tne 3.x branch. If you use Spring Boot 2.1.x higher than 2.1.14 it is broken as yukihane  already described. You can have a look here https://github.com/synyx/urlaubsverwaltung/tree/v3.x - and also see the commits of the Spring Boot 2.1.x versions we upgraded to test and downgraded again.

It would be really nice if this would be fixed so we can provided security patches in the 3.x. branch

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Oct 11, 2020

derTobsch commented

Totally forgot how you can see it. If you start the application and try to request an application for leave it will break

@spring-projects-issues spring-projects-issues added type: regression in: core labels Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: regression
Projects
None yet
Development

No branches or pull requests

2 participants