Why is micronaut invoking the wrong controller method?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Why is micronaut invoking the wrong controller method?



I have a micronaut API like this:


@Get("/")
List<Club> listClubs()

@Get("/{id}")
Club show(Long id)



In my unit test, when I invoke the show method, the listClubs() method is actually getting invoked, instead.


show


listClubs()



Why is this happening?



Details:



Thinking that my URL mappings must be wrong, I started debugging into Netty to try to understand how the framework constructs URLs.



In HttpClientIntroductionAdvice, the context shows the API method like this:


HttpClientIntroductionAdvice



Club show(Long param0)


Club show(Long param0)



The interceptor is setting param0 in the parameter map, which doesn't match the actual parameter name of my method. When the URI template is expanded, this causes the ID to get dropped (thus the URI becomes / instead of /1).


param0


/


/1



I am trying to follow this example:



https://github.com/alvarosanchez/micronaut-workshop/tree/master/ex02/solution/clubs



There is one important different in my project, which is that the endpoint is set at "/club" instead of at "/":


"/club"


"/"



@Controller("/club")


@Controller("/club")



@Client("/club")


@Client("/club")



I am using a diff tool to compare my project to the sample, but I am struggling to find any other difference (besides package name changes).



Why is this happening? What should I be looking for?



Thanks









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Regex - How to capture all iterations of a repeating pattern?