Skip to content

Commit d06ba4d

Browse files
committed
Merge branch 'master' into issue_37107
* master: Deprecate _type from LeafDocLookup (elastic#37491) Allow system privilege to execute proxied actions (elastic#37508) Update Put Watch to allow unknown fields (elastic#37494) AwaitsFix testAddNewReplicas SQL: Add protocol tests and remove jdbc_type from drivers response (elastic#37516) SQL: [Docs] Add an ES-SQL column for data types (elastic#37529) IndexMetaData#mappingOrDefault doesn't need to take a type argument. (elastic#37480) Simplify + Cleanup Dead Code in Settings (elastic#37341) Reject all requests that have an unconsumed body (elastic#37504) [Ml] Prevent config snapshot failure blocking migration (elastic#37493) Fix line length for aliases and remove suppression (elastic#37455) Add SSL Configuration Library (elastic#37287) SQL: Remove slightly used meta commands (elastic#37506) Simplify Snapshot Create Request Handling (elastic#37464) Remove the use of AbstracLifecycleComponent constructor elastic#37488 (elastic#37488) [ML] log minimum diskspace setting if forecast fails due to insufficient d… (elastic#37486)
2 parents 1345cc4 + 3d8c046 commit d06ba4d

File tree

175 files changed

+6558
-1700
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+6558
-1700
lines changed

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@
4646
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]WatcherDocumentationIT.java" id="SnippetLength" />
4747
<suppress files="modules[/\\]reindex[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]ReindexDocumentationIT.java" id="SnippetLength" />
4848

49-
<!-- Hopefully temporary suppression of LineLength on files that don't pass it. We should remove these when we the
50-
files start to pass. -->
51-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]aliases[/\\]IndexAliasesIT.java" checks="LineLength" />
52-
5349
<!-- Gradle requires inputs to be seriablizable -->
5450
<suppress files="buildSrc[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]gradle[/\\]precommit[/\\]TestingConventionRule.java" checks="RegexpSinglelineJava" />
5551
</suppressions>

client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/PutWatchResponse.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@
2020

2121
import org.elasticsearch.common.ParseField;
2222
import org.elasticsearch.common.xcontent.ObjectParser;
23-
import org.elasticsearch.common.xcontent.ToXContentObject;
24-
import org.elasticsearch.common.xcontent.XContentBuilder;
2523
import org.elasticsearch.common.xcontent.XContentParser;
2624

2725
import java.io.IOException;
2826
import java.util.Objects;
2927

30-
public class PutWatchResponse implements ToXContentObject {
28+
public class PutWatchResponse {
3129

3230
private static final ObjectParser<PutWatchResponse, Void> PARSER
33-
= new ObjectParser<>("x_pack_put_watch_response", PutWatchResponse::new);
31+
= new ObjectParser<>("x_pack_put_watch_response", true, PutWatchResponse::new);
3432

3533
static {
3634
PARSER.declareString(PutWatchResponse::setId, new ParseField("_id"));
@@ -90,15 +88,6 @@ public int hashCode() {
9088
return Objects.hash(id, version, created);
9189
}
9290

93-
@Override
94-
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
95-
return builder.startObject()
96-
.field("_id", id)
97-
.field("_version", version)
98-
.field("created", created)
99-
.endObject();
100-
}
101-
10291
public static PutWatchResponse fromXContent(XContentParser parser) throws IOException {
10392
return PARSER.parse(parser, null);
10493
}

client/rest-high-level/src/test/java/org/elasticsearch/client/watcher/PutWatchResponseTests.java

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,37 @@
1818
*/
1919
package org.elasticsearch.client.watcher;
2020

21-
import org.elasticsearch.common.xcontent.XContentParser;
22-
import org.elasticsearch.test.AbstractXContentTestCase;
21+
import org.elasticsearch.common.xcontent.XContentBuilder;
22+
import org.elasticsearch.test.ESTestCase;
2323

2424
import java.io.IOException;
2525

26-
public class PutWatchResponseTests extends AbstractXContentTestCase<PutWatchResponse> {
26+
import static org.elasticsearch.test.AbstractXContentTestCase.xContentTester;
2727

28-
@Override
29-
protected PutWatchResponse createTestInstance() {
30-
String id = randomAlphaOfLength(10);
31-
long version = randomLongBetween(1, 10);
32-
boolean created = randomBoolean();
33-
return new PutWatchResponse(id, version, created);
28+
public class PutWatchResponseTests extends ESTestCase {
29+
30+
public void testFromXContent() throws IOException {
31+
xContentTester(this::createParser,
32+
PutWatchResponseTests::createTestInstance,
33+
PutWatchResponseTests::toXContent,
34+
PutWatchResponse::fromXContent)
35+
.supportsUnknownFields(true)
36+
.assertToXContentEquivalence(false)
37+
.test();
3438
}
3539

36-
@Override
37-
protected PutWatchResponse doParseInstance(XContentParser parser) throws IOException {
38-
return PutWatchResponse.fromXContent(parser);
40+
private static XContentBuilder toXContent(PutWatchResponse response, XContentBuilder builder) throws IOException {
41+
return builder.startObject()
42+
.field("_id", response.getId())
43+
.field("_version", response.getVersion())
44+
.field("created", response.isCreated())
45+
.endObject();
3946
}
4047

41-
@Override
42-
protected boolean supportsUnknownFields() {
43-
return false;
48+
private static PutWatchResponse createTestInstance() {
49+
String id = randomAlphaOfLength(10);
50+
long version = randomLongBetween(1, 10);
51+
boolean created = randomBoolean();
52+
return new PutWatchResponse(id, version, created);
4453
}
4554
}

docs/reference/sql/language/data-types.asciidoc

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,44 @@
55

66
beta[]
77

8-
Most of {es} <<mapping-types, data types>> are available in {es-sql}, as indicated below:
8+
Most of {es} <<mapping-types, data types>> are available in {es-sql}, as indicated below.
9+
As one can see, all of {es} <<mapping-types, data types>> are mapped to the data type with the same
10+
name in {es-sql}, with the exception of **date** data type which is mapped to **datetime** in {es-sql}:
911

10-
[cols="^,^m,^"]
12+
[cols="^,^m,^,^"]
1113

1214
|===
1315
s|{es} type
16+
s|{es-sql} type
1417
s|SQL type
1518
s|SQL precision
1619

17-
3+h| Core types
18-
19-
| <<null-value, `null`>> | null | 0
20-
| <<boolean, `boolean`>> | boolean | 1
21-
| <<number, `byte`>> | tinyint | 3
22-
| <<number, `short`>> | smallint | 5
23-
| <<number, `integer`>> | integer | 10
24-
| <<number, `long`>> | bigint | 19
25-
| <<number, `double`>> | double | 15
26-
| <<number, `float`>> | real | 7
27-
| <<number, `half_float`>> | float | 16
28-
| <<number, `scaled_float`>> | float | 19
29-
| <<keyword, `keyword`>> | varchar | based on <<ignore-above>>
30-
| <<text, `text`>> | varchar | 2,147,483,647
31-
| <<binary, `binary`>> | varbinary | 2,147,483,647
32-
| <<date, `date`>> | timestamp | 24
33-
| <<ip, `ip`>> | varchar | 39
34-
35-
3+h| Complex types
36-
37-
| <<object, `object`>> | struct | 0
38-
| <<nested, `nested`>> | struct | 0
39-
40-
3+h| Unsupported types
41-
42-
| _types not mentioned above_ | unsupported | 0
20+
4+h| Core types
21+
22+
| <<null-value, `null`>> | null | NULL | 0
23+
| <<boolean, `boolean`>> | boolean | BOOLEAN | 1
24+
| <<number, `byte`>> | byte | TINYINT | 3
25+
| <<number, `short`>> | short | SMALLINT | 5
26+
| <<number, `integer`>> | integer | INTEGER | 10
27+
| <<number, `long`>> | long | BIGINT | 19
28+
| <<number, `double`>> | double | DOUBLE | 15
29+
| <<number, `float`>> | float | REAL | 7
30+
| <<number, `half_float`>> | half_float | FLOAT | 16
31+
| <<number, `scaled_float`>> | scaled_float | FLOAT | 19
32+
| <<keyword, `keyword`>> | keyword | VARCHAR | based on <<ignore-above>>
33+
| <<text, `text`>> | text | VARCHAR | 2,147,483,647
34+
| <<binary, `binary`>> | binary | VARBINARY | 2,147,483,647
35+
| <<date, `date`>> | datetime | TIMESTAMP | 24
36+
| <<ip, `ip`>> | ip | VARCHAR | 39
37+
38+
4+h| Complex types
39+
40+
| <<object, `object`>> | object | STRUCT | 0
41+
| <<nested, `nested`>> | nested | STRUCT | 0
42+
43+
4+h| Unsupported types
44+
45+
| _types not mentioned above_ | unsupported | OTHER | 0
4346

4447
|===
4548

libs/ssl-config/build.gradle

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
dependencies {
21+
compile "org.elasticsearch:elasticsearch-core:${version}"
22+
23+
if (isEclipse == false || project.path == ":libs:ssl-config-tests") {
24+
testCompile("org.elasticsearch.test:framework:${version}") {
25+
exclude group: 'org.elasticsearch', module: 'elasticsearch-ssl-config'
26+
}
27+
}
28+
29+
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
30+
testCompile "junit:junit:${versions.junit}"
31+
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
32+
}
33+
34+
forbiddenApisMain {
35+
replaceSignatureFiles 'jdk-signatures'
36+
}
37+
forbiddenPatterns {
38+
exclude '**/*.key'
39+
exclude '**/*.pem'
40+
exclude '**/*.p12'
41+
exclude '**/*.jks'
42+
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.common.ssl;
21+
22+
import org.elasticsearch.common.Nullable;
23+
24+
import javax.net.ssl.TrustManagerFactory;
25+
import javax.net.ssl.X509ExtendedTrustManager;
26+
import java.io.IOException;
27+
import java.nio.file.Path;
28+
import java.security.GeneralSecurityException;
29+
import java.security.KeyStore;
30+
import java.util.Arrays;
31+
import java.util.Collection;
32+
import java.util.Collections;
33+
import java.util.function.BiFunction;
34+
35+
/**
36+
* This class represents a trust configuration that corresponds to the default trusted CAs of the JDK
37+
*/
38+
final class DefaultJdkTrustConfig implements SslTrustConfig {
39+
40+
private final BiFunction<String, String, String> systemProperties;
41+
private final char[] trustStorePassword;
42+
43+
/**
44+
* Create a trust config that uses System properties to determine the TrustStore type, and the relevant password.
45+
*/
46+
DefaultJdkTrustConfig() {
47+
this(System::getProperty);
48+
}
49+
50+
/**
51+
* Create a trust config that uses supplied {@link BiFunction} to determine the TrustStore type, and the relevant password.
52+
*/
53+
DefaultJdkTrustConfig(BiFunction<String, String, String> systemProperties) {
54+
this(systemProperties, isPkcs11Truststore(systemProperties) ? getSystemTrustStorePassword(systemProperties) : null);
55+
}
56+
57+
/**
58+
* @param trustStorePassword the password for the truststore. It applies only when PKCS#11 tokens are used, is null otherwise
59+
*/
60+
DefaultJdkTrustConfig(BiFunction<String, String, String> systemProperties, @Nullable char[] trustStorePassword) {
61+
this.systemProperties = systemProperties;
62+
this.trustStorePassword = trustStorePassword;
63+
}
64+
65+
@Override
66+
public X509ExtendedTrustManager createTrustManager() {
67+
try {
68+
return KeyStoreUtil.createTrustManager(getSystemTrustStore(), TrustManagerFactory.getDefaultAlgorithm());
69+
} catch (GeneralSecurityException e) {
70+
throw new SslConfigException("failed to initialize a TrustManager for the system keystore", e);
71+
}
72+
}
73+
74+
/**
75+
* When a PKCS#11 token is used as the system default keystore/truststore, we need to pass the keystore
76+
* password when loading, even for reading certificates only ( as opposed to i.e. JKS keystores where
77+
* we only need to pass the password for reading Private Key entries ).
78+
*
79+
* @return the KeyStore used as truststore for PKCS#11 initialized with the password, null otherwise
80+
*/
81+
private KeyStore getSystemTrustStore() {
82+
if (isPkcs11Truststore(systemProperties) && trustStorePassword != null) {
83+
try {
84+
KeyStore keyStore = KeyStore.getInstance("PKCS11");
85+
keyStore.load(null, trustStorePassword);
86+
return keyStore;
87+
} catch (GeneralSecurityException | IOException e) {
88+
throw new SslConfigException("failed to load the system PKCS#11 truststore", e);
89+
}
90+
}
91+
return null;
92+
}
93+
94+
private static boolean isPkcs11Truststore(BiFunction<String, String, String> systemProperties) {
95+
return systemProperties.apply("javax.net.ssl.trustStoreType", "").equalsIgnoreCase("PKCS11");
96+
}
97+
98+
private static char[] getSystemTrustStorePassword(BiFunction<String, String, String> systemProperties) {
99+
return systemProperties.apply("javax.net.ssl.trustStorePassword", "").toCharArray();
100+
}
101+
102+
@Override
103+
public Collection<Path> getDependentFiles() {
104+
return Collections.emptyList();
105+
}
106+
107+
@Override
108+
public String toString() {
109+
return "JDK-trusted-certs";
110+
}
111+
112+
@Override
113+
public boolean equals(Object o) {
114+
if (this == o) {
115+
return true;
116+
}
117+
if (o == null || getClass() != o.getClass()) {
118+
return false;
119+
}
120+
final DefaultJdkTrustConfig that = (DefaultJdkTrustConfig) o;
121+
return Arrays.equals(this.trustStorePassword, that.trustStorePassword);
122+
}
123+
124+
@Override
125+
public int hashCode() {
126+
return Arrays.hashCode(trustStorePassword);
127+
}
128+
}

0 commit comments

Comments
 (0)