-
Notifications
You must be signed in to change notification settings - Fork 70
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
Maximum length for instance configs should be longer - improve tests. #147
Conversation
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.
Let's go forward with that! Here are a few comments to improve readability
@@ -415,7 +425,16 @@ public void doIteration() { | |||
|
|||
public boolean addConfig(String name, YamlParser config) { | |||
// named groups not supported with Java6: "(?<check>.{1,30})_(?<version>\\d{0,30})" |
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.
Should that comment be updated?
String patternText = AUTO_DISCOVERY_PREFIX+"_(.{1," + AD_MAX_NAME_LEN + | ||
"})_(\\d{0,"+ AD_MAX_MAG_INSTANCES +"})"; | ||
|
||
Pattern pattern = Pattern.compile(patternText); | ||
|
||
Matcher matcher = pattern.matcher(name); | ||
if (!matcher.find()) { |
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.
I'd love to have debug output here too, in case it were to happen
@@ -45,6 +46,9 @@ | |||
private static final String AD_LEGACY_CONFIG_SEP = "#### SERVICE-DISCOVERY ####"; | |||
private static final String AD_CONFIG_TERM = "#### AUTO-DISCOVERY TERM ####"; | |||
private static final String AD_LEGACY_CONFIG_TERM = "#### SERVICE-DISCOVERY TERM ####"; | |||
private static final int AD_MAX_NAME_LEN = 80; | |||
private static final int AD_MAX_MAG_INSTANCES = (int)Math.log10(1000) + 1; |
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.
That's a bit cryptic, I'd go with 4 // 1000 instances ought to be enough for anyone
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.
Last nitpick, other wise good to go!
@@ -414,19 +424,30 @@ public void doIteration() { | |||
} | |||
|
|||
public boolean addConfig(String name, YamlParser config) { | |||
// named groups not supported with Java6: "(?<check>.{1,30})_(?<version>\\d{0,30})" | |||
Pattern pattern = Pattern.compile(AUTO_DISCOVERY_PREFIX+"(.{1,30})_(\\d{0,30})"); | |||
// named groups not supported with Java6: "(?<check>.{1,80})_(?<version>\\d{0,80})" |
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.
I think it's (?<version>\\d{0,4})
right, using AD_MAX_MAG_INSTANCES
?
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.
👍
No description provided.