spring-projects / spring-projects/spring-tools

"Unknown property" marker is created when there is a setter but no getter

Open
#1,180 15 comments 0 reactions 1 assignee View on GitHub

@BoykoAlex is already working on this.

Since Feb 5, 2024.

for: eclipse for: vscode theme: property-editing-support type: bug
Dominant language
Java
Stars
983
Forks
240
Avg merge
7d 1h
Merged PRs (30d)
7

Description

STS for Eclipse Version: 4.21.0.RELEASE

In application config YAML files, STS will mark a property as unknown (error or warning depending on how I have STS configured) even if there is a setter for that property in the corresponding Java @ConfigurationProperties class. If I have both getter and setter, the error/warning goes away.

For example, given this class:

@ConfigurationProperties(prefix = "foo")
public class MyProperties {
	private String envName;
	public void setEnvName(String name) { };
}

and this YAML:

foo:
  envName: bar

STS puts an error/warning marker in the YAML saying envName is an unknown property.

If I add this getter to MyProperties:

	public String getEnvName() { return ""; }

Then the YAML error/warning goes away.

It seems that a property with only a setter shouldn't trigger an error/warning, since all that matters to Spring is that it can know where to put the value from the YAML.
Before anyone starts quoting the Java Beans spec to me, I know that a property with no getter is not a strict Java Beans property. Practically speaking, however, Spring doesn't care; it still correctly sets the YAML value into the config object. So STS is not agreeing with Spring's own runtime behavior.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.