Skip to content

Spring Boot Language Server processing java.util.Properties type configuration logic error #534

Closed

Description

@octoape

Problem

Configure the property name spring.datasource.hikari.data-source-properties[v$session.program]=myappin application.properties.
But problem is that the spring boot language server prompts an error Can't use '[..]' navigation for property 'spring.datasource.hikari.data-source-properties' of type java.util.Properties.

Environment

Spring Boot: 2.2.8.RELEASE
Oracle JDK: 1.8.0_192
Eclipse: 2020-06 (4.16.0)
Spring Boot Language Server: 4.7.2.202009020949

Related issue

https://github.com/spring-projects/spring-boot/issues/23238

Activity

  1. kdvolder commented on Sep 15, 2020

    @kdvolder
    Member

    I can reproduce this issue.

    Steps:

    • create new boot project with web and actuator starter using initializer wizard
    • Add the sample code as given by @shanlaomao to application.properties file.

    => error shown on the text between [..].

    This is definitely something we should fix.

    However for this particular example it seems like the '[..]' notation while it is indeed 'valid' and shouldn't be flagged as an error... is actually not necessary.

    I create a property class myself to test this out:

    package com.example.demo;
    
    import java.util.Properties;
    
    import org.springframework.boot.context.properties.ConfigurationProperties;
    
    @ConfigurationProperties("my")
    public class MyProps {
    
    	private Properties stuff = new Properties();
    
    	public Properties getStuff() {
    		return stuff;
    	}
    
    	
    }
    

    And I made my app read these properties and print them out to test how they get bound.

    When I create a properties file like this:

    my.stuff.v$session.program=myapp
    

    The 'stuff' properties object gets populated with a map entry of v$session.program=myapp. So this seems like it doesn't need the [..] to escape the special characters at all (I think this because the java.util.Properties is a special case and doesn't support further navigation with .. So therefore it isn't necessary to escape these dots.

    Anyhow long story short:

    • yes this is a bug and we should fix it but...
    • as a workaround I think you can simply use the notation without [..].

    However, I am a little confused with comments from the other bug ticket. These suggest that using the . notation isn't working, in that example. But I don't understand why that would be the case... it seems to work fine for me with the property that I defined. Maybe there is something special about the properties in spring.datasource.hikari.data-source-properties ?

    Maybe @wilkinsona can clarify.

    Also I wonder if this behavior might vary on different versions of Spring Boot (I am trying this with Boot 2.4.M2 and there escaping the . seems not needed.

  2. kdvolder commented on Sep 15, 2020

    @kdvolder
    Member

    Okay, so switching my test app to Boot 2.2.8... and indeed in that case escaping is necessary. Without escaping the key becomes vsession.program instead of v$session.program.

  3. added this to the 4.8.1.RELEASE milestone on Sep 17, 2020
  4. spring-projects-issues commented on Sep 17, 2020

    @spring-projects-issues

    (comment in Pivotal Tracker added by Kris De Volder:)

    Follow up ticket: https://www.pivotaltracker.com/story/show/174872660

    I think we have similar issue in .yml and also the conversion from .properties to yml.

  5. spring-projects-issues commented on Sep 25, 2020

    @spring-projects-issues

    (comment in Pivotal Tracker added by Nieraj Singh:)

    Accepted using:

    Version: 4.8.1.CI-B2455
    Build Id: 202009251902

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions