Merge pull request elastic/elasticsearch#50 from rmuir/parent_cleanups_forbidden

Sync up with elasticsearch-parent changes:

Original commit: elastic/x-pack-elasticsearch@420b0cbd3e
This commit is contained in:
Robert Muir 2015-05-21 17:15:35 -04:00
commit 19e1b5597c
14 changed files with 60 additions and 356 deletions

View File

@ -13,20 +13,7 @@
<properties>
<license.basedir combine.self="override">${project.parent.basedir}</license.basedir>
<tests.ifNoTests>warn</tests.ifNoTests>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>junit4-maven-plugin</artifactId>
<executions>
<execution>
<id>tests</id>
<phase/>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
</project>

View File

@ -20,12 +20,4 @@
<version>2.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>junit4-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
</project>

View File

@ -1,3 +0,0 @@
@defaultMessage Convert to URI
java.net.URL#getPath()
java.net.URL#getFile()

View File

@ -1,65 +0,0 @@
@defaultMessage spawns threads with vague names; use a custom thread factory and name threads so that you can tell (by its name) which executor it is associated with
java.util.concurrent.Executors#newFixedThreadPool(int)
java.util.concurrent.Executors#newSingleThreadExecutor()
java.util.concurrent.Executors#newCachedThreadPool()
java.util.concurrent.Executors#newSingleThreadScheduledExecutor()
java.util.concurrent.Executors#newScheduledThreadPool(int)
java.util.concurrent.Executors#defaultThreadFactory()
java.util.concurrent.Executors#privilegedThreadFactory()
java.lang.Character#codePointBefore(char[],int) @ Implicit start offset is error-prone when the char[] is a buffer and the first chars are random chars
java.lang.Character#codePointAt(char[],int) @ Implicit end offset is error-prone when the char[] is a buffer and the last chars are random chars
@defaultMessage Collections.sort dumps data into an array, sorts the array and reinserts data into the list, one should rather use Lucene's CollectionUtil sort methods which sort in place
java.util.Collections#sort(java.util.List)
java.util.Collections#sort(java.util.List,java.util.Comparator)
java.io.StringReader#<init>(java.lang.String) @ Use FastStringReader instead
@defaultMessage Reference management is tricky, leave it to SearcherManager
org.apache.lucene.index.IndexReader#decRef()
org.apache.lucene.index.IndexReader#incRef()
org.apache.lucene.index.IndexReader#tryIncRef()
@defaultMessage QueryWrapperFilter is cachable by default - use Queries#wrap instead
org.apache.lucene.search.QueryWrapperFilter#<init>(org.apache.lucene.search.Query)
@defaultMessage Because the filtercache doesn't take deletes into account FilteredQuery can't be used - use XFilteredQuery instead
org.apache.lucene.search.FilteredQuery#<init>(org.apache.lucene.search.Query,org.apache.lucene.search.Filter)
org.apache.lucene.search.FilteredQuery#<init>(org.apache.lucene.search.Query,org.apache.lucene.search.Filter,org.apache.lucene.search.FilteredQuery$FilterStrategy)
@defaultMessage Pass the precision step from the mappings explicitly instead
org.apache.lucene.search.NumericRangeQuery#newDoubleRange(java.lang.String,java.lang.Double,java.lang.Double,boolean,boolean)
org.apache.lucene.search.NumericRangeQuery#newFloatRange(java.lang.String,java.lang.Float,java.lang.Float,boolean,boolean)
org.apache.lucene.search.NumericRangeQuery#newIntRange(java.lang.String,java.lang.Integer,java.lang.Integer,boolean,boolean)
org.apache.lucene.search.NumericRangeQuery#newLongRange(java.lang.String,java.lang.Long,java.lang.Long,boolean,boolean)
org.apache.lucene.search.NumericRangeFilter#newDoubleRange(java.lang.String,java.lang.Double,java.lang.Double,boolean,boolean)
org.apache.lucene.search.NumericRangeFilter#newFloatRange(java.lang.String,java.lang.Float,java.lang.Float,boolean,boolean)
org.apache.lucene.search.NumericRangeFilter#newIntRange(java.lang.String,java.lang.Integer,java.lang.Integer,boolean,boolean)
org.apache.lucene.search.NumericRangeFilter#newLongRange(java.lang.String,java.lang.Long,java.lang.Long,boolean,boolean)
@defaultMessage Only use wait / notify when really needed try to use concurrency primitives, latches or callbacks instead.
java.lang.Object#wait()
java.lang.Object#wait(long)
java.lang.Object#wait(long,int)
java.lang.Object#notify()
java.lang.Object#notifyAll()
@defaultMessage Beware of the behavior of this method on MIN_VALUE
java.lang.Math#abs(int)
java.lang.Math#abs(long)
@defaultMessage Please do not try to stop the world
java.lang.System#gc()
@defaultMessage Use Channels.* methods to write to channels. Do not write directly.
java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
java.nio.channels.FileChannel#write(java.nio.ByteBuffer, long)
java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[], int, int)
java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[])
java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[])
java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[], int, int)
java.nio.channels.FileChannel#read(java.nio.ByteBuffer, long)

View File

@ -13,6 +13,8 @@
<properties>
<license.basedir combine.self="override">${project.parent.basedir}</license.basedir>
<elasticsearch.assembly.descriptor>${basedir}/src/main/assemblies/exec.xml</elasticsearch.assembly.descriptor>
<elasticsearch.assembly.appendId>true</elasticsearch.assembly.appendId>
</properties>
<dependencies>
@ -24,34 +26,10 @@
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
</configuration>
<executions>
<execution>
<id>exec</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
<descriptors>
<descriptor>${basedir}/src/main/assemblies/exec.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -73,10 +51,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>junit4-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
</project>

View File

@ -6,6 +6,8 @@
package org.elasticsearch.license.licensor;
import org.elasticsearch.common.Base64;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.collect.ImmutableSet;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
@ -19,7 +21,6 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.*;
import java.util.Collections;
import java.util.Set;
@ -28,6 +29,7 @@ import java.util.Set;
* Responsible for generating a license signature according to
* the signature spec and sign it with the provided encrypted private key
*/
@SuppressForbidden(reason = "can we avoid bare string paths and resolve from Environment or similar?")
public class LicenseSigner {
private final static int MAGIC_LENGTH = 13;
@ -37,7 +39,7 @@ public class LicenseSigner {
private final Path privateKeyPath;
public LicenseSigner(final String privateKeyPath, final String publicKeyPath) {
this(Paths.get(privateKeyPath), Paths.get(publicKeyPath));
this(PathUtils.get(privateKeyPath), PathUtils.get(publicKeyPath));
}
public LicenseSigner(final Path privateKeyPath, final Path publicKeyPath) {

View File

@ -15,7 +15,6 @@ import org.elasticsearch.env.Environment;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
@ -40,7 +39,7 @@ public class KeyPairGeneratorTool extends CliTool {
@Override
protected Command parse(String s, CommandLine commandLine) throws Exception {
return KeyGenerator.parse(terminal, commandLine);
return KeyGenerator.parse(terminal, commandLine, env);
}
public static class KeyGenerator extends Command {
@ -60,9 +59,9 @@ public class KeyPairGeneratorTool extends CliTool {
this.publicKeyPath = publicKeyPath;
}
public static Command parse(Terminal terminal, CommandLine commandLine) {
Path publicKeyPath = Paths.get(commandLine.getOptionValue("publicKeyPath"));
Path privateKeyPath = Paths.get(commandLine.getOptionValue("privateKeyPath"));
public static Command parse(Terminal terminal, CommandLine commandLine, Environment environment) {
Path publicKeyPath = environment.homeFile().resolve(commandLine.getOptionValue("publicKeyPath"));
Path privateKeyPath = environment.homeFile().resolve(commandLine.getOptionValue("privateKeyPath"));
if (Files.exists(privateKeyPath)) {
return exitCmd(ExitStatus.USAGE, terminal, privateKeyPath + " already exists");

View File

@ -24,7 +24,6 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashSet;
import java.util.Set;
@ -45,7 +44,7 @@ public class LicenseGeneratorTool extends CliTool {
@Override
protected Command parse(String s, CommandLine commandLine) throws Exception {
return LicenseGenerator.parse(terminal, commandLine);
return LicenseGenerator.parse(terminal, commandLine, env);
}
public static class LicenseGenerator extends Command {
@ -69,9 +68,9 @@ public class LicenseGeneratorTool extends CliTool {
this.publicKeyFilePath = publicKeyFilePath;
}
public static Command parse(Terminal terminal, CommandLine commandLine) throws IOException {
Path publicKeyPath = Paths.get(commandLine.getOptionValue("publicKeyPath"));
Path privateKeyPath = Paths.get(commandLine.getOptionValue("privateKeyPath"));
public static Command parse(Terminal terminal, CommandLine commandLine, Environment environment) throws IOException {
Path publicKeyPath = environment.homeFile().resolve(commandLine.getOptionValue("publicKeyPath"));
Path privateKeyPath = environment.homeFile().resolve(commandLine.getOptionValue("privateKeyPath"));
String[] licenseSpecSources = commandLine.getOptionValues("license");
String[] licenseSpecSourceFiles = commandLine.getOptionValues("licenseFile");
@ -90,7 +89,7 @@ public class LicenseGeneratorTool extends CliTool {
if (licenseSpecSourceFiles != null) {
for (String licenseSpecFilePath : licenseSpecSourceFiles) {
Path licenseSpecPath = Paths.get(licenseSpecFilePath);
Path licenseSpecPath = environment.homeFile().resolve(licenseSpecFilePath);
if (!Files.exists(licenseSpecPath)) {
return exitCmd(ExitStatus.USAGE, terminal, licenseSpecFilePath + " does not exist");
}

View File

@ -19,12 +19,10 @@ import org.elasticsearch.license.core.License;
import org.elasticsearch.license.core.LicenseVerifier;
import org.elasticsearch.license.core.Licenses;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@ -46,7 +44,7 @@ public class LicenseVerificationTool extends CliTool {
@Override
protected Command parse(String s, CommandLine commandLine) throws Exception {
return LicenseVerifier.parse(terminal, commandLine);
return LicenseVerifier.parse(terminal, commandLine, env);
}
public static class LicenseVerifier extends Command {
@ -67,7 +65,7 @@ public class LicenseVerificationTool extends CliTool {
this.publicKeyPath = publicKeyPath;
}
public static Command parse(Terminal terminal, CommandLine commandLine) throws IOException {
public static Command parse(Terminal terminal, CommandLine commandLine, Environment environment) throws IOException {
String publicKeyPathString = commandLine.getOptionValue("publicKeyPath");
String[] licenseSources = commandLine.getOptionValues("license");
String[] licenseSourceFiles = commandLine.getOptionValues("licenseFile");
@ -81,7 +79,7 @@ public class LicenseVerificationTool extends CliTool {
if (licenseSourceFiles != null) {
for (String licenseFilePath : licenseSourceFiles) {
Path licensePath = Paths.get(licenseFilePath);
Path licensePath = environment.homeFile().resolve(licenseFilePath);
if (!Files.exists(licensePath)) {
return exitCmd(ExitStatus.USAGE, terminal, licenseFilePath + " does not exist");
}
@ -93,7 +91,7 @@ public class LicenseVerificationTool extends CliTool {
return exitCmd(ExitStatus.USAGE, terminal, "no license provided");
}
Path publicKeyPath = Paths.get(publicKeyPathString);
Path publicKeyPath = environment.homeFile().resolve(publicKeyPathString);
if (!Files.exists(publicKeyPath)) {
return exitCmd(ExitStatus.USAGE, terminal, publicKeyPath + " does not exist");
}

View File

@ -15,7 +15,6 @@ import org.junit.Test;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.elasticsearch.common.cli.CliTool.Command;
import static org.elasticsearch.common.cli.CliTool.ExitStatus;
@ -72,21 +71,17 @@ public class KeyPairGenerationToolTests extends CliToolTestCase {
@Test
public void testToolSimple() throws Exception {
KeyPairGeneratorTool keyPairGeneratorTool = new KeyPairGeneratorTool();
Path tempFile1 = createTempFile();
Path tempFile2 = createTempFile();
String publicKeyPath = tempFile1.toAbsolutePath().toString();
String privateKeyPath = tempFile2.toAbsolutePath().toString();
Path publicKeyFilePath = Paths.get(publicKeyPath);
Path privateKeyFilePath = Paths.get(privateKeyPath);
Path publicKeyFilePath = createTempFile().toAbsolutePath();
Path privateKeyFilePath = createTempFile().toAbsolutePath();
Settings settings = ImmutableSettings.builder().put("path.home", createTempDir()).build();
Files.delete(tempFile1);
Files.delete(tempFile2);
assertThat(Files.exists(tempFile1), equalTo(false));
assertThat(Files.exists(tempFile2), equalTo(false));
Files.delete(publicKeyFilePath);
Files.delete(privateKeyFilePath);
assertThat(Files.exists(publicKeyFilePath), equalTo(false));
assertThat(Files.exists(privateKeyFilePath), equalTo(false));
Command command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, new String[] { "--privateKeyPath", privateKeyPath,
"--publicKeyPath", publicKeyPath });
Command command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, new String[] { "--privateKeyPath", privateKeyFilePath.toString(),
"--publicKeyPath", publicKeyFilePath.toString() });
assertThat(command, instanceOf(KeyGenerator.class));
KeyGenerator keyGenerator = (KeyGenerator) command;

View File

@ -19,7 +19,6 @@ import org.junit.Test;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import static org.elasticsearch.common.cli.CliTool.ExitStatus;
@ -32,16 +31,16 @@ import static org.hamcrest.core.IsEqual.equalTo;
public class LicenseGenerationToolTests extends CliToolTestCase {
protected String pubKeyPath = null;
protected String priKeyPath = null;
protected Path pubKeyPath = null;
protected Path priKeyPath = null;
protected Path homeDir = null;
@Before
public void setup() throws Exception {
logger.error("project.basedir [{}]", System.getProperty("project.basedir"));
pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE).toString();
priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE).toString();
pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE);
priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE);
homeDir = createTempDir();
}
@ -51,8 +50,8 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
new String[] {"--license", TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)),
"--publicKeyPath", pubKeyPath.concat("invalid"),
"--privateKeyPath", priKeyPath });
"--publicKeyPath", pubKeyPath.toString().concat("invalid"),
"--privateKeyPath", priKeyPath.toString() });
assertThat(command, instanceOf(Command.Exit.class));
Command.Exit exitCommand = (Command.Exit) command;
@ -60,8 +59,8 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
new String[] {"--license", TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)),
"--privateKeyPath", priKeyPath.concat("invalid"),
"--publicKeyPath", pubKeyPath });
"--privateKeyPath", priKeyPath.toString().concat("invalid"),
"--publicKeyPath", pubKeyPath.toString() });
assertThat(command, instanceOf(Command.Exit.class));
exitCommand = (Command.Exit) command;
@ -72,8 +71,8 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
public void testParsingMissingLicenseSpec() throws Exception {
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
new String[] { "--publicKeyPath", pubKeyPath,
"--privateKeyPath", priKeyPath });
new String[] { "--publicKeyPath", pubKeyPath.toString(),
"--privateKeyPath", priKeyPath.toString() });
assertThat(command, instanceOf(Command.Exit.class));
Command.Exit exitCommand = (Command.Exit) command;
@ -89,7 +88,7 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
new String[] { "--license", TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)),
((pubKeyMissing) ? "--privateKeyPath" : "--publicKeyPath"),
((pubKeyMissing) ? priKeyPath : pubKeyPath) });
((pubKeyMissing) ? priKeyPath.toString() : pubKeyPath.toString()) });
fail("missing argument: " + ((pubKeyMissing) ? "publicKeyPath" : "privateKeyPath") + " should throw an exception");
} catch (MissingOptionException e) {
assertThat(e.getMessage(), containsString((pubKeyMissing) ? "pub" : "pri"));
@ -102,13 +101,13 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
new String[]{"--license", TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)),
"--publicKeyPath", pubKeyPath,
"--privateKeyPath", priKeyPath });
"--publicKeyPath", pubKeyPath.toString(),
"--privateKeyPath", priKeyPath.toString() });
assertThat(command, instanceOf(LicenseGenerator.class));
LicenseGenerator licenseGenerator = (LicenseGenerator) command;
assertThat(licenseGenerator.publicKeyFilePath, equalTo(Paths.get(pubKeyPath)));
assertThat(licenseGenerator.privateKeyFilePath, equalTo(Paths.get(priKeyPath)));
assertThat(licenseGenerator.publicKeyFilePath, equalTo(pubKeyPath));
assertThat(licenseGenerator.privateKeyFilePath, equalTo(priKeyPath));
assertThat(licenseGenerator.licenseSpecs.size(), equalTo(1));
License outputLicenseSpec = licenseGenerator.licenseSpecs.iterator().next();
@ -124,13 +123,13 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
new String[] { "--licenseFile", tempFile.toAbsolutePath().toString(),
"--publicKeyPath", pubKeyPath,
"--privateKeyPath", priKeyPath });
"--publicKeyPath", pubKeyPath.toString(),
"--privateKeyPath", priKeyPath.toString() });
assertThat(command, instanceOf(LicenseGenerator.class));
LicenseGenerator licenseGenerator = (LicenseGenerator) command;
assertThat(licenseGenerator.publicKeyFilePath, equalTo(Paths.get(pubKeyPath)));
assertThat(licenseGenerator.privateKeyFilePath, equalTo(Paths.get(priKeyPath)));
assertThat(licenseGenerator.publicKeyFilePath, equalTo(pubKeyPath));
assertThat(licenseGenerator.privateKeyFilePath, equalTo(priKeyPath));
assertThat(licenseGenerator.licenseSpecs.size(), equalTo(1));
License outputLicenseSpec = licenseGenerator.licenseSpecs.iterator().next();
@ -148,13 +147,13 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
new String[] { "--license", TestUtils.generateLicenseSpecString(new ArrayList<>(inputLicenseSpecs.values())),
"--publicKeyPath", pubKeyPath,
"--privateKeyPath", priKeyPath });
"--publicKeyPath", pubKeyPath.toString(),
"--privateKeyPath", priKeyPath.toString() });
assertThat(command, instanceOf(LicenseGenerator.class));
LicenseGenerator licenseGenerator = (LicenseGenerator) command;
assertThat(licenseGenerator.publicKeyFilePath, equalTo(Paths.get(pubKeyPath)));
assertThat(licenseGenerator.privateKeyFilePath, equalTo(Paths.get(priKeyPath)));
assertThat(licenseGenerator.publicKeyFilePath, equalTo(pubKeyPath));
assertThat(licenseGenerator.privateKeyFilePath, equalTo(priKeyPath));
assertThat(licenseGenerator.licenseSpecs.size(), equalTo(inputLicenseSpecs.size()));
for (License outputLicenseSpec : licenseGenerator.licenseSpecs) {
@ -174,7 +173,7 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
}
List<License> licenseSpecs = Licenses.fromSource(TestUtils.generateLicenseSpecString(new ArrayList<>(inputLicenseSpecs.values())).getBytes(StandardCharsets.UTF_8), false);
String output = runLicenseGenerationTool(Paths.get(pubKeyPath), Paths.get(priKeyPath), new HashSet<>(licenseSpecs), ExitStatus.OK);
String output = runLicenseGenerationTool(pubKeyPath, priKeyPath, new HashSet<>(licenseSpecs), ExitStatus.OK);
List<License> outputLicenses = Licenses.fromSource(output.getBytes(StandardCharsets.UTF_8), true);
assertThat(outputLicenses.size(), equalTo(inputLicenseSpecs.size()));

View File

@ -26,6 +26,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.common.util.concurrent.FutureUtils;
import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.license.core.License;
import org.elasticsearch.license.core.LicenseVerifier;
@ -352,12 +353,12 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
// cancel all notifications
for (ScheduledFuture scheduledNotification : scheduledNotifications) {
scheduledNotification.cancel(true);
FutureUtils.cancel(scheduledNotification);
}
for (Queue<ScheduledFuture> queue : eventNotificationsMap.values()) {
for (ScheduledFuture scheduledFuture : queue) {
scheduledFuture.cancel(true);
FutureUtils.cancel(scheduledFuture);
}
queue.clear();
}
@ -927,7 +928,7 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
ScheduledFuture notification = notificationQueue.peek();
if (notification != null) {
// cancel
notification.cancel(true);
FutureUtils.cancel(notification);
notificationQueue.poll();
}
}

174
pom.xml
View File

@ -25,182 +25,8 @@
<license.basedir combine.self="override">${project.basedir}</license.basedir>
</properties>
<dependencies>
<!-- test deps -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>randomizedtesting-runner</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>test</scope>
</dependency>
<!-- actual deps -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<fork>true</fork>
<maxmem>512m</maxmem>
<!-- REMOVE WHEN UPGRADE:
see https://jira.codehaus.org/browse/MCOMPILER-209 it's a bug where
incremental compilation doesn't work unless it's set to false causeing
recompilation of the entire codebase each time without any changes. Should
be fixed in version > 3.1
-->
<useIncrementalCompilation>false</useIncrementalCompilation>
<compilerArgs>
<arg>-XDignore.symbol.file</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<!-- we skip surefire to work with randomized testing above -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>de.thetaphi</groupId>
<artifactId>forbiddenapis</artifactId>
<executions>
<execution>
<id>check-forbidden-apis</id>
<configuration>
<targetVersion>1.7</targetVersion>
<!-- disallow undocumented classes like sun.misc.Unsafe: -->
<internalRuntimeForbidden>true</internalRuntimeForbidden>
<!-- if the used Java version is too new, don't fail, just do nothing: -->
<failOnUnsupportedJava>false</failOnUnsupportedJava>
<excludes>
<exclude>jsr166e/**</exclude>
<!-- start excludes for valid system-out -->
<exclude>org/elasticsearch/shield/support/cli/Terminal*</exclude>
<exclude>org/elasticsearch/common/logging/log4j/ConsoleAppender*</exclude>
<exclude>org/elasticsearch/plugins/PluginManager.class</exclude>
<exclude>org/elasticsearch/bootstrap/Bootstrap.class</exclude>
<exclude>org/elasticsearch/Version.class</exclude>
<exclude>
org/elasticsearch/common/lucene/search/Queries$QueryWrapperFilterFactory.class
</exclude>
<!-- end excludes for valid system-out -->
<!-- start excludes for Unsafe -->
<exclude>org/elasticsearch/common/util/UnsafeUtils.class</exclude>
<!-- end excludes for Unsafe -->
<!-- start excludes for Math.abs -->
<exclude>org/elasticsearch/common/util/MathUtils.class</exclude>
<exclude>org/elasticsearch/common/math/UnboxedMathUtils.class</exclude>
<exclude>org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.class
</exclude>
<!-- end excludes for Math.abs -->
<!-- start exclude for FilteredQuery -->
<exclude>org/elasticsearch/common/lucene/search/XFilteredQuery.class</exclude>
<!-- end exclude for FilteredQuery -->
<!-- start exclude for Channels utility class -->
<exclude>org/elasticsearch/common/io/Channels.class</exclude>
<!-- end exclude for Channels -->
</excludes>
<bundledSignatures>
<!-- This will automatically choose the right signatures based on 'targetVersion': -->
<bundledSignature>jdk-unsafe</bundledSignature>
<bundledSignature>jdk-deprecated</bundledSignature>
<bundledSignature>jdk-system-out</bundledSignature>
</bundledSignatures>
<signaturesFiles>
<signaturesFile>${license.basedir}/dev-tools/forbidden/core-signatures.txt</signaturesFile>
<signaturesFile>${license.basedir}/dev-tools/forbidden/all-signatures.txt</signaturesFile>
</signaturesFiles>
<signatures>${forbidden.signatures}</signatures>
</configuration>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
<execution>
<id>check-forbidden-test-apis</id>
<configuration>
<targetVersion>1.7</targetVersion>
<!-- disallow undocumented classes like sun.misc.Unsafe: -->
<internalRuntimeForbidden>true</internalRuntimeForbidden>
<!-- if the used Java version is too new, don't fail, just do nothing: -->
<failOnUnsupportedJava>false</failOnUnsupportedJava>
<bundledSignatures>
<!-- This will automatically choose the right signatures based on 'targetVersion': -->
<bundledSignature>jdk-unsafe</bundledSignature>
<bundledSignature>jdk-deprecated</bundledSignature>
</bundledSignatures>
<signaturesFiles>
<signaturesFile>${license.basedir}/dev-tools/forbidden/test-signatures.txt</signaturesFile>
<signaturesFile>${license.basedir}/dev-tools/forbidden/all-signatures.txt</signaturesFile>
</signaturesFiles>
<signatures>${forbidden.test.signatures}</signatures>
</configuration>
<phase>test-compile</phase>
<goals>
<goal>testCheck</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.7,)</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>