Merge branch 'master' into lists_are_simple
This commit is contained in:
commit
69ba45a797
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.common.settings.loader;
|
package org.elasticsearch.common.settings.loader;
|
||||||
|
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.io.FastStringReader;
|
import org.elasticsearch.common.io.FastStringReader;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ public class PropertiesSettingsLoader implements SettingsLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> load(String source) throws IOException {
|
public Map<String, String> load(String source) throws IOException {
|
||||||
Properties props = new Properties();
|
Properties props = new NoDuplicatesProperties();
|
||||||
FastStringReader reader = new FastStringReader(source);
|
FastStringReader reader = new FastStringReader(source);
|
||||||
try {
|
try {
|
||||||
props.load(reader);
|
props.load(reader);
|
||||||
|
@ -52,7 +53,7 @@ public class PropertiesSettingsLoader implements SettingsLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> load(byte[] source) throws IOException {
|
public Map<String, String> load(byte[] source) throws IOException {
|
||||||
Properties props = new Properties();
|
Properties props = new NoDuplicatesProperties();
|
||||||
StreamInput stream = StreamInput.wrap(source);
|
StreamInput stream = StreamInput.wrap(source);
|
||||||
try {
|
try {
|
||||||
props.load(stream);
|
props.load(stream);
|
||||||
|
@ -65,4 +66,15 @@ public class PropertiesSettingsLoader implements SettingsLoader {
|
||||||
IOUtils.closeWhileHandlingException(stream);
|
IOUtils.closeWhileHandlingException(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NoDuplicatesProperties extends Properties {
|
||||||
|
@Override
|
||||||
|
public synchronized Object put(Object key, Object value) {
|
||||||
|
Object previousValue = super.put(key, value);
|
||||||
|
if (previousValue != null) {
|
||||||
|
throw new ElasticsearchParseException("duplicate settings key [{}] found, previous value [{}], current value [{}]", key, previousValue, value);
|
||||||
|
}
|
||||||
|
return previousValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package org.elasticsearch.common.settings.loader;
|
package org.elasticsearch.common.settings.loader;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.xcontent.XContent;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
|
@ -141,7 +140,18 @@ public abstract class XContentSettingsLoader implements SettingsLoader {
|
||||||
sb.append(pathEle).append('.');
|
sb.append(pathEle).append('.');
|
||||||
}
|
}
|
||||||
sb.append(fieldName);
|
sb.append(fieldName);
|
||||||
settings.put(sb.toString(), parser.text());
|
String key = sb.toString();
|
||||||
|
String currentValue = parser.text();
|
||||||
|
String previousValue = settings.put(key, currentValue);
|
||||||
|
if (previousValue != null) {
|
||||||
|
throw new ElasticsearchParseException(
|
||||||
|
"duplicate settings key [{}] found at line number [{}], column number [{}], previous value [{}], current value [{}]",
|
||||||
|
key,
|
||||||
|
parser.getTokenLocation().lineNumber,
|
||||||
|
parser.getTokenLocation().columnNumber,
|
||||||
|
previousValue,
|
||||||
|
currentValue
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,19 +19,19 @@
|
||||||
|
|
||||||
package org.elasticsearch.common.settings.loader;
|
package org.elasticsearch.common.settings.loader;
|
||||||
|
|
||||||
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
import org.elasticsearch.common.settings.SettingsException;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class JsonSettingsLoaderTests extends ESTestCase {
|
public class JsonSettingsLoaderTests extends ESTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleJsonSettings() throws Exception {
|
public void testSimpleJsonSettings() throws Exception {
|
||||||
String json = "/org/elasticsearch/common/settings/loader/test-settings.json";
|
String json = "/org/elasticsearch/common/settings/loader/test-settings.json";
|
||||||
|
@ -50,4 +50,17 @@ public class JsonSettingsLoaderTests extends ESTestCase {
|
||||||
assertThat(settings.getAsArray("test1.test3")[0], equalTo("test3-1"));
|
assertThat(settings.getAsArray("test1.test3")[0], equalTo("test3-1"));
|
||||||
assertThat(settings.getAsArray("test1.test3")[1], equalTo("test3-2"));
|
assertThat(settings.getAsArray("test1.test3")[1], equalTo("test3-2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDuplicateKeysThrowsException() {
|
||||||
|
String json = "{\"foo\":\"bar\",\"foo\":\"baz\"}";
|
||||||
|
try {
|
||||||
|
settingsBuilder()
|
||||||
|
.loadFromSource(json)
|
||||||
|
.build();
|
||||||
|
fail("expected exception");
|
||||||
|
} catch (SettingsException e) {
|
||||||
|
assertEquals(e.getCause().getClass(), ElasticsearchParseException.class);
|
||||||
|
assertTrue(e.toString().contains("duplicate settings key [foo] found at line number [1], column number [13], previous value [bar], current value [baz]"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Licensed to Elasticsearch under one or more contributor
|
||||||
|
* license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright
|
||||||
|
* ownership. Elasticsearch licenses this file to you under
|
||||||
|
* the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
* not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.elasticsearch.common.settings.loader;
|
||||||
|
|
||||||
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
public class PropertiesSettingsLoaderTests extends ESTestCase {
|
||||||
|
public void testDuplicateKeyFromStringThrowsException() throws IOException {
|
||||||
|
PropertiesSettingsLoader loader = new PropertiesSettingsLoader();
|
||||||
|
try {
|
||||||
|
loader.load("foo=bar\nfoo=baz");
|
||||||
|
fail("expected exception");
|
||||||
|
} catch (ElasticsearchParseException e) {
|
||||||
|
assertEquals(e.getMessage(), "duplicate settings key [foo] found, previous value [bar], current value [baz]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDuplicateKeysFromBytesThrowsException() throws IOException {
|
||||||
|
PropertiesSettingsLoader loader = new PropertiesSettingsLoader();
|
||||||
|
try {
|
||||||
|
loader.load("foo=bar\nfoo=baz".getBytes(Charset.defaultCharset()));
|
||||||
|
} catch (ElasticsearchParseException e) {
|
||||||
|
assertEquals(e.getMessage(), "duplicate settings key [foo] found, previous value [bar], current value [baz]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.elasticsearch.common.settings.loader;
|
package org.elasticsearch.common.settings.loader;
|
||||||
|
|
||||||
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.SettingsException;
|
import org.elasticsearch.common.settings.SettingsException;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
@ -31,7 +32,6 @@ import static org.hamcrest.Matchers.equalTo;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class YamlSettingsLoaderTests extends ESTestCase {
|
public class YamlSettingsLoaderTests extends ESTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleYamlSettings() throws Exception {
|
public void testSimpleYamlSettings() throws Exception {
|
||||||
String yaml = "/org/elasticsearch/common/settings/loader/test-settings.yml";
|
String yaml = "/org/elasticsearch/common/settings/loader/test-settings.yml";
|
||||||
|
@ -66,4 +66,17 @@ public class YamlSettingsLoaderTests extends ESTestCase {
|
||||||
.loadFromStream(yaml, getClass().getResourceAsStream(yaml))
|
.loadFromStream(yaml, getClass().getResourceAsStream(yaml))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void testDuplicateKeysThrowsException() {
|
||||||
|
String yaml = "foo: bar\nfoo: baz";
|
||||||
|
try {
|
||||||
|
settingsBuilder()
|
||||||
|
.loadFromSource(yaml)
|
||||||
|
.build();
|
||||||
|
fail("expected exception");
|
||||||
|
} catch (SettingsException e) {
|
||||||
|
assertEquals(e.getCause().getClass(), ElasticsearchParseException.class);
|
||||||
|
assertTrue(e.toString().contains("duplicate settings key [foo] found at line number [2], column number [6], previous value [bar], current value [baz]"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,12 +6,13 @@
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<listEntry value="1"/>
|
<listEntry value="1"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<mapAttribute key="org.eclipse.debug.core.environmentVariables">
|
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||||
<mapEntry key="ES_HOME" value="${target_home}"/>
|
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||||
</mapAttribute>
|
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
|
</listAttribute>
|
||||||
|
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.elasticsearch.bootstrap.Elasticsearch"/>
|
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.elasticsearch.bootstrap.Elasticsearch"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="start"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="elasticsearch"/>
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="elasticsearch"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
|
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/heapdump.hprof -Delasticsearch -Des.foreground=yes -ea -Des.path.home=target/eclipse_run -Des.security.manager.enabled=false"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=logs/heapdump.hprof -Delasticsearch -Des.foreground=yes -ea"/>
|
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
|
@ -90,6 +90,15 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-eclipse-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<!-- Many of the modules in this build have the artifactId "elasticsearch"
|
||||||
|
which break importing into Eclipse without this. -->
|
||||||
|
<projectNameTemplate>[groupId].[artifactId]</projectNameTemplate>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
9732a4e80aad23101faa442700c2172a37257c43
|
|
|
@ -0,0 +1 @@
|
||||||
|
7ff51040bbcc9085dcb9a24a2c2a3cc7ac995988
|
|
@ -1 +0,0 @@
|
||||||
b5dc3760021fba0ae67b4f11d37ffa52a4eac4f4
|
|
|
@ -0,0 +1 @@
|
||||||
|
b0712cc659e72b9da0f5b03872d2476ab4a695f7
|
|
@ -1 +0,0 @@
|
||||||
48f0aab551fa9e2eb4c81e2debf40e9fff595405
|
|
|
@ -0,0 +1 @@
|
||||||
|
31afbe46b65e9933316c7e8dfb8b88dc4b37b6ba
|
|
@ -1 +0,0 @@
|
||||||
891e42d29e8f9474f83c050e4ee6a4512d4f4e71
|
|
|
@ -0,0 +1 @@
|
||||||
|
c9e2593fdf398c5f8906a704db037d17b2de4b2a
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<elasticsearch.plugin.classname>org.elasticsearch.plugin.cloud.aws.CloudAwsPlugin</elasticsearch.plugin.classname>
|
<elasticsearch.plugin.classname>org.elasticsearch.plugin.cloud.aws.CloudAwsPlugin</elasticsearch.plugin.classname>
|
||||||
<amazonaws.version>1.10.0</amazonaws.version>
|
<amazonaws.version>1.10.12</amazonaws.version>
|
||||||
<tests.jvms>1</tests.jvms>
|
<tests.jvms>1</tests.jvms>
|
||||||
<tests.rest.suite>cloud_aws</tests.rest.suite>
|
<tests.rest.suite>cloud_aws</tests.rest.suite>
|
||||||
<tests.rest.load_packaged>false</tests.rest.load_packaged>
|
<tests.rest.load_packaged>false</tests.rest.load_packaged>
|
||||||
|
|
|
@ -34,7 +34,6 @@ import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.common.SuppressForbidden;
|
import org.elasticsearch.common.SuppressForbidden;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -579,4 +578,54 @@ public class AmazonS3Wrapper implements AmazonS3 {
|
||||||
public boolean isRequesterPaysEnabled(String bucketName) throws AmazonServiceException, AmazonClientException {
|
public boolean isRequesterPaysEnabled(String bucketName) throws AmazonServiceException, AmazonClientException {
|
||||||
return delegate.isRequesterPaysEnabled(bucketName);
|
return delegate.isRequesterPaysEnabled(bucketName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectListing listNextBatchOfObjects(ListNextBatchOfObjectsRequest listNextBatchOfObjectsRequest) throws AmazonClientException, AmazonServiceException {
|
||||||
|
return delegate.listNextBatchOfObjects(listNextBatchOfObjectsRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VersionListing listNextBatchOfVersions(ListNextBatchOfVersionsRequest listNextBatchOfVersionsRequest) throws AmazonClientException, AmazonServiceException {
|
||||||
|
return delegate.listNextBatchOfVersions(listNextBatchOfVersionsRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Owner getS3AccountOwner(GetS3AccountOwnerRequest getS3AccountOwnerRequest) throws AmazonClientException, AmazonServiceException {
|
||||||
|
return delegate.getS3AccountOwner(getS3AccountOwnerRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BucketLoggingConfiguration getBucketLoggingConfiguration(GetBucketLoggingConfigurationRequest getBucketLoggingConfigurationRequest) throws AmazonClientException, AmazonServiceException {
|
||||||
|
return delegate.getBucketLoggingConfiguration(getBucketLoggingConfigurationRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BucketVersioningConfiguration getBucketVersioningConfiguration(GetBucketVersioningConfigurationRequest getBucketVersioningConfigurationRequest) throws AmazonClientException, AmazonServiceException {
|
||||||
|
return delegate.getBucketVersioningConfiguration(getBucketVersioningConfigurationRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BucketLifecycleConfiguration getBucketLifecycleConfiguration(GetBucketLifecycleConfigurationRequest getBucketLifecycleConfigurationRequest) {
|
||||||
|
return delegate.getBucketLifecycleConfiguration(getBucketLifecycleConfigurationRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BucketCrossOriginConfiguration getBucketCrossOriginConfiguration(GetBucketCrossOriginConfigurationRequest getBucketCrossOriginConfigurationRequest) {
|
||||||
|
return delegate.getBucketCrossOriginConfiguration(getBucketCrossOriginConfigurationRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BucketTaggingConfiguration getBucketTaggingConfiguration(GetBucketTaggingConfigurationRequest getBucketTaggingConfigurationRequest) {
|
||||||
|
return delegate.getBucketTaggingConfiguration(getBucketTaggingConfigurationRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BucketNotificationConfiguration getBucketNotificationConfiguration(GetBucketNotificationConfigurationRequest getBucketNotificationConfigurationRequest) throws AmazonClientException, AmazonServiceException {
|
||||||
|
return delegate.getBucketNotificationConfiguration(getBucketNotificationConfigurationRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BucketReplicationConfiguration getBucketReplicationConfiguration(GetBucketReplicationConfigurationRequest getBucketReplicationConfigurationRequest) throws AmazonServiceException, AmazonClientException {
|
||||||
|
return delegate.getBucketReplicationConfiguration(getBucketReplicationConfigurationRequest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -982,7 +982,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-eclipse-plugin</artifactId>
|
<artifactId>maven-eclipse-plugin</artifactId>
|
||||||
<version>2.9</version>
|
<version>2.10</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<buildOutputDirectory>eclipse-build</buildOutputDirectory>
|
<buildOutputDirectory>eclipse-build</buildOutputDirectory>
|
||||||
<downloadSources>true</downloadSources>
|
<downloadSources>true</downloadSources>
|
||||||
|
|
Loading…
Reference in New Issue