Skip to content

[refactoring] quick fix to convert autowired field to constructor param shows up even if the constructor param already exists #815

@martinlippert

Description

@martinlippert

I have a class like this:

@Component
public class MySomething {
	
    @Autowired
    private String something;

    MySomething(String something) {
        this.something = something;
    }
}

The quick fix to convert the autowired field into a constructor param shows up, even through the constructor param already exists. This should not be the case. Instead, a quick fix should be around to remove the autowired annotation only.

In addition to that, when I execute the quick fix, it results in:

@Component
public class MySomething {
	
    private String something;

    MySomething(String something, String something, String something) {
        this.something = something;
        this.something = something;
        this.something = something;
    }
}

So I end up having the same constructor param three (!) times.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions