Spring-cloud-gateway: Should we must limit lb:// protocol use host format?

Created on 22 Feb 2019  路  2Comments  路  Source: spring-cloud/spring-cloud-gateway

Hi!Thanks the wonderful project.
I have some confuse with the lb:// check design.
Using lb://order_app will throw a exception of java.lang.IllegalStateException: Invalid host: lb://order_app because order_app is NOT a host scheme. Exception throw from here:

if("lb".equalsIgnoreCase(routeUri.getScheme()) && routeUri.getHost() == null) {
    //Load balanced URIs should always have a host.  If the host is null it is most
    /likely because the host name was invalid (for example included an underscore)
    throw new IllegalStateException("Invalid host: " + routeUri.toString());
}

Why limit application name with a host format?
Is there a best practice to name a application?

There also has some conflict with Spring Cloud Config if use order-app as a name. Because Spring Cloud Config use - distinct environment in some situation.

question

Most helpful comment

dont use lb://order_app , but use lb://order-app .Because URI don鈥榯 support underline.

All 2 comments

It's an assumption we make many places in spring cloud. We use spring framework URI utilities and java's URI class which is where the limitation comes from.

If we did anything, it would be during a major release (which will not happen for a long time, think spring framework 6 or spring boot 3). We would have to rework all locations to use some custom class. I personally don't want to spend the effort.

dont use lb://order_app , but use lb://order-app .Because URI don鈥榯 support underline.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pravinkumarb84 picture pravinkumarb84  路  7Comments

dennis-menge picture dennis-menge  路  4Comments

esacaceres picture esacaceres  路  7Comments

vborcea picture vborcea  路  6Comments

thirunar picture thirunar  路  6Comments