Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Adding two methods with the same name lead to duplicated method names in generated code #1266

Closed
ViniciusArnhold opened this issue Nov 16, 2021 · 5 comments
Labels
type: bug A general bug
Milestone

Comments

@ViniciusArnhold
Copy link

Hi, while trying to compile a project which uses Playtika/feign-reactive with spring-native 0.11.0-SNAPSHOT we've been hitting the following compilation error:

> Task :reactive-feign-app:compileAotMainJava
/home/runner/work/spring-native-experiments/spring-native-experiments/reactive-feign-app/build/generated/sources/aotMain/reactivefeign/spring/config/ContextBootstrapInitializer.java:23: error: method registerReactiveFeignClientSpecification(GenericApplicationContext) is already defined in class ContextBootstrapInitializer
  public static void registerReactiveFeignClientSpecification(GenericApplicationContext context) {
                     ^

build action log

reactivefeign/spring/config/ContextBootstrapInitializer.java contents
public final class ContextBootstrapInitializer {
  public static void registerReactiveFeignClientSpecification(GenericApplicationContext context) {
    BeanDefinitionRegistrar.of("default.dev.viniciusarnhold.experiments.aot.app.ReactiveFeignApplication.ReactiveFeignClientSpecification", ReactiveFeignClientSpecification.class).withConstructor(String.class, Class[].class)
        .instanceSupplier((instanceContext) -> instanceContext.create(context, (attributes) -> new ReactiveFeignClientSpecification(attributes.get(0), attributes.get(1)))).customize((bd) -> {
      ConstructorArgumentValues argumentValues = bd.getConstructorArgumentValues();
      argumentValues.addIndexedArgumentValue(0, "default.dev.viniciusarnhold.experiments.aot.app.ReactiveFeignApplication");
      argumentValues.addIndexedArgumentValue(1, new String[] {  });
    }).register(context);
  }

  public static void registerReactiveFeignClientSpecification(GenericApplicationContext context) {
    BeanDefinitionRegistrar.of("github.ReactiveFeignClientSpecification", ReactiveFeignClientSpecification.class).withConstructor(String.class, Class[].class)
        .instanceSupplier((instanceContext) -> instanceContext.create(context, (attributes) -> new ReactiveFeignClientSpecification(attributes.get(0), attributes.get(1)))).customize((bd) -> {
      ConstructorArgumentValues argumentValues = bd.getConstructorArgumentValues();
      argumentValues.addIndexedArgumentValue(0, "github");
      argumentValues.addIndexedArgumentValue(1, new Class[] {  });
    }).register(context);
  }

  public static void registerReactiveFeignClientFactoryBean(GenericApplicationContext context) {
    BeanDefinitionRegistrar.of("dev.viniciusarnhold.experiments.aot.app.client.GithubClient", ReactiveFeignClientFactoryBean.class)
        .instanceSupplier(ReactiveFeignClientFactoryBean::new).customize((bd) -> {
      bd.setPrimary(true);
      MutablePropertyValues propertyValues = bd.getPropertyValues();
      propertyValues.addPropertyValue("url", "");
      propertyValues.addPropertyValue("path", "");
      propertyValues.addPropertyValue("name", "github");
      propertyValues.addPropertyValue("type", "dev.viniciusarnhold.experiments.aot.app.client.GithubClient");
      propertyValues.addPropertyValue("decode404", false);
      propertyValues.addPropertyValue("fallback", void.class);
      propertyValues.addPropertyValue("fallbackFactory", void.class);
    }).register(context);
  }

  public static void registerReactiveFeignAutoConfiguration(GenericApplicationContext context) {
    BeanDefinitionRegistrar.of("reactivefeign.spring.config.ReactiveFeignAutoConfiguration", ReactiveFeignAutoConfiguration.class)
        .instanceSupplier((instanceContext) -> {
          ReactiveFeignAutoConfiguration bean = new ReactiveFeignAutoConfiguration();
          instanceContext.field("configurations", List.class)
              .resolve(context, false).ifResolved((attributes) -> {
                Field configurationsField = ReflectionUtils.findField(ReactiveFeignAutoConfiguration.class, "configurations", List.class);
                ReflectionUtils.makeAccessible(configurationsField);
                ReflectionUtils.setField(configurationsField, bean, attributes.get(0));
              });
              return bean;
            }).register(context);
      }
    }

It started to occur sometime after 0.11.0-M2 (in M2 we have an infinite recursion on ConfigurationProperties with java.lang.Class attributes, which has been fixed in HEAD)

Is this an expected problem which has to be fixed in reactive-feign, or a problem in spring-native?
Apart from this problem, spring-native has been working great for us!

How to reproduce

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 16, 2021
@snicoll
Copy link
Contributor

snicoll commented Nov 17, 2021

@ViniciusArnhold thanks for the report. I doubt feign would work in its current form as it creates a child context at runtime that isn't supported by Spring AOT.

Apart from this problem, spring-native has been working great for us!

Do you mean your sample worked with 0.11.0.M1 ?

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Nov 18, 2021
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Nov 25, 2021
@ViniciusArnhold
Copy link
Author

ViniciusArnhold commented Dec 1, 2021

I doubt feign would work in its current form as it creates a child context at runtime that isn't supported by Spring AOT.

Ok, thanks for the explanation.

Do you mean your sample worked with 0.11.0.M1 ?

I meant the usage of other spring projects, such as spring-data, this specific sample never worked.

@snicoll
Copy link
Contributor

snicoll commented Dec 1, 2021

Thanks for the follow up. Let's see if we can do something about the duplicate still. We might also support child context at some point.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Dec 1, 2021
@snicoll snicoll added theme: aot type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels Dec 2, 2021
@snicoll snicoll added this to the 0.11.0 milestone Dec 2, 2021
@snicoll snicoll changed the title Duplicated method names generated in ContextBootstrapInitializer when using Playtika/feign-reactive Adding two methods with the same name lead to duplicated method names in generated code Dec 2, 2021
@snicoll
Copy link
Contributor

snicoll commented Dec 2, 2021

@ViniciusArnhold I've repurposed this issue to focus on the duplication. The sample should build now but feign won't work until we add support for that. Thanks for the sample!

@snicoll snicoll closed this as completed in deffea4 Dec 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A general bug
Development

No branches or pull requests

3 participants