Skip to content
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

Merged
merged 4 commits into from
Aug 7, 2017

Conversation

truthbk
Copy link
Member

@truthbk truthbk commented Jul 18, 2017

No description provided.

Copy link
Contributor

@xvello xvello left a 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})"
Copy link
Contributor

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()) {
Copy link
Contributor

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;
Copy link
Contributor

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

Copy link
Contributor

@xvello xvello left a 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})"
Copy link
Contributor

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?

Copy link
Contributor

@xvello xvello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@truthbk truthbk merged commit c2b1a84 into master Aug 7, 2017
@truthbk truthbk deleted the jaime/namebug branch August 7, 2017 09:51
@olivielpeau olivielpeau added this to the 0.16.0 milestone Aug 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants