Skip to content

Commit

Permalink
Merge branch 'master' into line-length-100
Browse files Browse the repository at this point in the history
* master:
  Docs: Add comma to reverse nested agg snippet
  Fix third-party audit task for Gradle 3.4 (elastic#23612)
  Adapter action future should restore interrupts
  Update scripting.asciidoc
  Unmark reindex as experimental
  • Loading branch information
jasontedor committed Mar 17, 2017
2 parents f01f493 + 413bf05 commit 82057aa
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,11 @@ public class ThirdPartyAuditTask extends AntTask {
try {
ant.thirdPartyAudit(failOnUnsupportedJava: false,
failOnMissingClasses: false,
signaturesFile: new File(getClass().getResource('/forbidden/third-party-audit.txt').toURI()),
classpath: classpath.asPath) {
fileset(dir: tmpDir)
signatures {
string(value: getClass().getResourceAsStream('/forbidden/third-party-audit.txt').getText('UTF-8'))
}
}
} catch (BuildException ignore) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public T actionGet() {
try {
return get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Future got interrupted", e);
} catch (ExecutionException e) {
throw rethrowExecutionException(e);
Expand Down Expand Up @@ -66,6 +67,7 @@ public T actionGet(long timeout, TimeUnit unit) {
} catch (TimeoutException e) {
throw new ElasticsearchTimeoutException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Future got interrupted", e);
} catch (ExecutionException e) {
throw rethrowExecutionException(e);
Expand Down Expand Up @@ -100,4 +102,5 @@ public void onFailure(Exception e) {
}

protected abstract T convert(L listenerResponse);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* 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.action.support;

import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESTestCase;

import java.util.Objects;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

public class AdapterActionFutureTests extends ESTestCase {

public void testInterruption() throws Exception {
final AdapterActionFuture<String, Integer> adapter =
new AdapterActionFuture<String, Integer>() {
@Override
protected String convert(final Integer listenerResponse) {
return Objects.toString(listenerResponse);
}
};

// test all possible methods that can be interrupted
final Runnable runnable = () -> {
final int method = randomIntBetween(0, 4);
switch (method) {
case 0:
adapter.actionGet();
break;
case 1:
adapter.actionGet("30s");
break;
case 2:
adapter.actionGet(30000);
break;
case 3:
adapter.actionGet(TimeValue.timeValueSeconds(30));
break;
case 4:
adapter.actionGet(30, TimeUnit.SECONDS);
break;
default:
throw new AssertionError(method);
}
};

final CyclicBarrier barrier = new CyclicBarrier(2);
final Thread main = Thread.currentThread();
final Thread thread = new Thread(() -> {
try {
barrier.await();
} catch (final BrokenBarrierException | InterruptedException e) {
throw new RuntimeException(e);
}
main.interrupt();
});
thread.start();

barrier.await();

final AtomicBoolean interrupted = new AtomicBoolean();
try {
runnable.run();
} catch (final IllegalStateException e) {
interrupted.set(Thread.currentThread().isInterrupted());
}
// we check this here instead of in the catch block to ensure that the catch block executed
assertTrue(interrupted.get());

thread.join();
}

}
2 changes: 0 additions & 2 deletions docs/java-api/docs/update-by-query.asciidoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[[docs-update-by-query]]
== Update By Query API

experimental[The update-by-query API is new and should still be considered experimental. The API may change in ways that are not backwards compatible]

The simplest usage of `updateByQuery` updates each
document in an index without changing the source. This usage enables
<<picking-up-a-new-property,picking up a new property>> or another online
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ the issue documents as nested documents. The mapping could look like:
"issue" : {
"properties" : {
"tags" : { "type" : "text" }
"tags" : { "type" : "text" },
"comments" : { <1>
"type" : "nested"
"type" : "nested",
"properties" : {
"username" : { "type" : "keyword" },
"comment" : { "type" : "text" }
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/docs/delete-by-query.asciidoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[[docs-delete-by-query]]
== Delete By Query API

experimental[The delete-by-query API is new and should still be considered experimental. The API may change in ways that are not backwards compatible]

The simplest usage of `_delete_by_query` just performs a deletion on every
document that match a query. Here is the API:

Expand Down
2 changes: 0 additions & 2 deletions docs/reference/docs/reindex.asciidoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[[docs-reindex]]
== Reindex API

experimental[The reindex API is new and should still be considered experimental. The API may change in ways that are not backwards compatible]

IMPORTANT: Reindex does not attempt to set up the destination index. It does
not copy the settings of the source index. You should set up the destination
index prior to running a `_reindex` action, including setting up mappings, shard
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/migration/migrate_6_0/scripting.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Use painless instead.

==== Date fields now return dates

`doc.some_date_field.value` now returns `ReadableDateTime`s instead of
`doc.some_date_field.value` now returns ++ReadableDateTime++s instead of
milliseconds since epoch as a `long`. The same is true for
`doc.some_date_field[some_number]`. Use `doc.some_date_field.value.millis` to
fetch the milliseconds since epoch if you need it.

0 comments on commit 82057aa

Please sign in to comment.