Skip to content

Commit

Permalink
refactor:Refactor findByClasspathBootstrapProperties method and findB…
Browse files Browse the repository at this point in the history
…yClasspathApplicationProperties method in SpringBootServiceNameDetector.java
  • Loading branch information
AlchemyDing authored Nov 6, 2023
1 parent 81249fc commit ab92ddc
Showing 1 changed file with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,12 @@ private String findBySystemProperties() {

@Nullable
private String findByClasspathApplicationProperties() {
String result = readNameFromAppProperties();
logger.log(
FINER, "Checking for spring.application.name in application.properties file: {0}", result);
return result;
return findByClasspathPropertiesFile("application.properties");
}

@Nullable
private String findByClasspathBootstrapProperties() {
String result = readNameFromBootstrapProperties();
logger.log(
FINER, "Checking for spring.application.name in bootstrap.properties file: {0}", result);
return result;
return findByClasspathPropertiesFile("bootstrap.properties");
}

@Nullable
Expand Down Expand Up @@ -279,15 +273,16 @@ private static String parseNameFromProcessArgs(String[] args) {
}

@Nullable
private String readNameFromAppProperties() {
return loadFromClasspath(
"application.properties", SpringBootServiceNameDetector::getAppNamePropertyFromStream);
}

@Nullable
private String readNameFromBootstrapProperties() {
return loadFromClasspath(
"bootstrap.properties", SpringBootServiceNameDetector::getAppNamePropertyFromStream);
private String findByClasspathPropertiesFile(String filename) {
String result =
loadFromClasspath(filename, SpringBootServiceNameDetector::getAppNamePropertyFromStream);
if (logger.isLoggable(FINER)) {
logger.log(
FINER,
"Checking for spring.application.name in {0} file: {1}",
new Object[] {filename, result});
}
return result;
}

@Nullable
Expand Down

0 comments on commit ab92ddc

Please sign in to comment.