-
Notifications
You must be signed in to change notification settings - Fork 14
add MultiBizProperties assert in web sample #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,13 +20,18 @@ | |
| import org.springframework.boot.builder.SpringApplicationBuilder; | ||
| import org.springframework.core.io.DefaultResourceLoader; | ||
| import org.springframework.core.io.ResourceLoader; | ||
| import org.springframework.util.Assert; | ||
|
|
||
| @SpringBootApplication | ||
| public class Biz2Application { | ||
|
|
||
| public static void main(String[] args) { | ||
| SpringApplicationBuilder builder = new SpringApplicationBuilder(Biz2Application.class); | ||
|
|
||
| // System.setProperty("app.name", "biz2"); | ||
| // if not set app.name, use value "base" from base application | ||
| Assert.isTrue("base".equals(System.getProperty("app.name")), "app.name is not biz2"); | ||
|
Comment on lines
+31
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Based on the shell script results, I can now generate a final response as the verification is complete. The results show clear patterns of app.name usage across different applications: The app.name assertion is incorrect and needs to be fixed Looking at the codebase patterns:
The commented code should be uncommented and the assertion should be updated to match the pattern seen in other applications: System.setProperty("app.name", "biz2");
Assert.isTrue("biz2".equals(System.getProperty("app.name")), "app.name is not biz2");🔗 Analysis chainPlease clarify the expected app.name value and fix inconsistencies. There are several inconsistencies in the app.name validation:
This creates confusion about whether this application should use "base" or "biz2" as its app.name. Let's check how other applications handle this: Please clarify:
🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check app.name handling across other application classes
# Expected: Find patterns of app.name usage to understand the intended behavior
# Search for app.name related code in other application classes
rg -l "app\.name" | grep -i "application\.java" | xargs rg "app\.name" -B 2 -A 2
Length of output: 3321 |
||
|
|
||
| // set biz to use resource loader. | ||
| ResourceLoader resourceLoader = new DefaultResourceLoader( | ||
| Biz2Application.class.getClassLoader()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider extracting "base" as a constant.
The hardcoded string "base" is used multiple times. Consider extracting it as a class constant for better maintainability and to avoid typos.
public class BaseApplication { private static Logger LOGGER = LoggerFactory.getLogger(BaseApplication.class); + private static final String APP_NAME = "base"; public static void main(String[] args) { MultiBizProperties.initSystem(); - System.setProperty("app.name", "base"); - Assert.isTrue("base".equals(System.getProperty("app.name")), "app.name is not base"); + System.setProperty("app.name", APP_NAME); + Assert.isTrue(APP_NAME.equals(System.getProperty("app.name")), + String.format("Expected app.name to be '%s' but was '%s'", APP_NAME, System.getProperty("app.name")));📝 Committable suggestion