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

Detect duplicate settings keys on startup #13086

Merged
merged 1 commit into from Aug 25, 2015
Merged

Detect duplicate settings keys on startup #13086

merged 1 commit into from Aug 25, 2015

Conversation

jasontedor
Copy link
Member

This commit changes the startup behavior of Elasticsearch to throw an
exception if duplicate settings keys are detected in the Elasticsearch
configuration file.

Closes #13079

@jasontedor jasontedor added >bug review :Core/Infra/Core Core issues without another label v2.0.0 labels Aug 24, 2015
@s1monw
Copy link
Contributor

s1monw commented Aug 24, 2015

I didn't really look close enough here but I wonder what happen if I have foo: bar defined in the yml file and specify -Des.foo=bar on the cmd - will it fail or override it?

@jasontedor
Copy link
Member Author

@s1monw I can push a commit that will cause that to fail too.


/**
*
*/
public class JsonSettingsLoaderTests extends ESTestCase {
@Rule
public ExpectedException expectedException = ExpectedException.none();
Copy link
Member

Choose a reason for hiding this comment

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

Is this the default?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it has to be specified.

@s1monw
Copy link
Contributor

s1monw commented Aug 24, 2015

@jasontedor should it fail? I mean I would expect the -D to override whatever is configured?

@jasontedor
Copy link
Member Author

Sorry for the miscommunication here; I misunderstood your first question as you implicitly wanting that change.

To be clear, with this pull request as it currently stands, the only change is that duplicates in the configuration file will cause an exception at startup. Settings can still be specified on the command line and will not cause an exception if settings with the same key are also in the configuration file. Settings on the command line still take precedence.

@Test
public void testDuplicateKeysThrowsException() {
expectedException.expect(SettingsException.class);
expectedException.expectCause(Matchers.<Throwable>instanceOf(ElasticsearchParseException.class));
Copy link
Member

Choose a reason for hiding this comment

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

Can we just use a simple try/catch here? I don't see why we need to use hamcrest complicatedness...

Copy link
Member

Choose a reason for hiding this comment

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

or junit for that matter. try/catch is much more readable (and the way most other tests do this)

Copy link
Member Author

Choose a reason for hiding this comment

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

ACK. I pushed a commit that I agree is simpler.

@rjernst
Copy link
Member

rjernst commented Aug 25, 2015

lgtm

This commit changes the startup behavior of Elasticsearch to throw an
exception if duplicate settings keys are detected in the Elasticsearch
configuration file.

Closes #13079
jasontedor added a commit that referenced this pull request Aug 25, 2015
Detect duplicate settings keys on startup
@jasontedor jasontedor merged commit 51ae1c4 into elastic:master Aug 25, 2015
@jasontedor jasontedor deleted the fix/no-duplicate-settings branch August 25, 2015 00:51
@jasontedor
Copy link
Member Author

Thanks for the helpful review @rjernst.

jasontedor added a commit that referenced this pull request Aug 25, 2015
This commit backports the fix #13086 for #13079 to 2.0 from master.
@jasontedor jasontedor removed the review label Aug 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Core Core issues without another label v2.0.0-beta2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants