Skip to content

Different property resolution if property value is empty #22793

Closed

Description

@renetrefft

Affects: 5.1.6 / 4.3.23 + Spring Tools 4.2.0

@Component
public class PropertiesTest {

	@Value("${key}")
	String property;

        @Value("${key}")
	String[] propertyArr;
	
}

If a property key is defined without a value in application.properties (i.e. key=) the variable property is initialized with an empty String and propertyArr with an empty String array.

If key is defined without a value in a 'Spring Boot App' Eclipse launch configuration instead ("Override Properties" feature) the start of the application fails:

java.lang.IllegalArgumentException: Could not resolve placeholder 'key' in value "${key}"

Spring should always resolve a property with an empty value as an empty String / String array.

Activity

  1. added
    status: waiting-for-triage
    on Apr 14, 2019
  2. sbrannen commented on Apr 14, 2019

    @sbrannen
    Member

    It sounds to me like this is an issue with Spring Tools 4.

    In light of that, I recommend you open an issue in the Spring Tools issue tracker, and I will close this issue here.

    /cc @martinlippert

  3. added
    for: external-project
    and removed
    status: waiting-for-triage
    on Apr 14, 2019
  4. martinlippert commented on Apr 15, 2019

    @martinlippert
    Member

    looks like this is indeed an issue with the boot launch support in the Spring Tools, not setting empty values from the custom properties of the launch in the same way than empty values in the properties file. Filed an issue here:

    spring-projects/spring-tools#275

  5. sbrannen commented on Apr 15, 2019

    @sbrannen
    Member
  6. martinlippert commented on Apr 17, 2019

    @martinlippert
    Member

    Quick update: this is fixed now, will be released as part of the Spring Tools 4.2.1 release, coming later this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-project

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions