Merge pull request #13531 from rmuir/die_setaccessible_die

Ban setAccessible from core code, restore monitoring stats under java 9
This commit is contained in:
Robert Muir 2015-09-12 03:31:40 -04:00
commit e1efd5f6ba
113 changed files with 250 additions and 248 deletions

View File

@ -30,7 +30,7 @@ import java.io.IOException;
*/
public abstract class ActionRequest<T extends ActionRequest> extends TransportRequest {
protected ActionRequest() {
public ActionRequest() {
super();
}

View File

@ -47,7 +47,7 @@ public class ClusterHealthRequest extends MasterNodeReadRequest<ClusterHealthReq
private String waitForNodes = "";
private Priority waitForEvents = null;
ClusterHealthRequest() {
public ClusterHealthRequest() {
}
public ClusterHealthRequest(String... indices) {

View File

@ -124,7 +124,7 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
if (request.waitForNodes().isEmpty()) {
waitFor--;
}
if (request.indices().length == 0) { // check that they actually exists in the meta data
if (request.indices() == null || request.indices().length == 0) { // check that they actually exists in the meta data
waitFor--;
}
@ -199,7 +199,7 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
if (request.waitForActiveShards() != -1 && response.getActiveShards() >= request.waitForActiveShards()) {
waitForCounter++;
}
if (request.indices().length > 0) {
if (request.indices() != null && request.indices().length > 0) {
try {
indexNameExpressionResolver.concreteIndices(clusterState, IndicesOptions.strictExpand(), request.indices());
waitForCounter++;

View File

@ -38,7 +38,7 @@ public class NodesHotThreadsRequest extends BaseNodesRequest<NodesHotThreadsRequ
boolean ignoreIdleThreads = true;
// for serialization
NodesHotThreadsRequest() {
public NodesHotThreadsRequest() {
}

View File

@ -94,11 +94,11 @@ public class TransportNodesHotThreadsAction extends TransportNodesAction<NodesHo
return false;
}
static class NodeRequest extends BaseNodeRequest {
public static class NodeRequest extends BaseNodeRequest {
NodesHotThreadsRequest request;
NodeRequest() {
public NodeRequest() {
}
NodeRequest(String nodeId, NodesHotThreadsRequest request) {

View File

@ -88,11 +88,11 @@ public class TransportNodesInfoAction extends TransportNodesAction<NodesInfoRequ
return false;
}
static class NodeInfoRequest extends BaseNodeRequest {
public static class NodeInfoRequest extends BaseNodeRequest {
NodesInfoRequest request;
NodeInfoRequest() {
public NodeInfoRequest() {
}
NodeInfoRequest(String nodeId, NodesInfoRequest request) {

View File

@ -42,7 +42,7 @@ public class NodesStatsRequest extends BaseNodesRequest<NodesStatsRequest> {
private boolean breaker;
private boolean script;
protected NodesStatsRequest() {
public NodesStatsRequest() {
}
/**

View File

@ -88,11 +88,11 @@ public class TransportNodesStatsAction extends TransportNodesAction<NodesStatsRe
return false;
}
static class NodeStatsRequest extends BaseNodeRequest {
public static class NodeStatsRequest extends BaseNodeRequest {
NodesStatsRequest request;
NodeStatsRequest() {
public NodeStatsRequest() {
}
NodeStatsRequest(String nodeId, NodesStatsRequest request) {

View File

@ -37,7 +37,7 @@ public class DeleteRepositoryRequest extends AcknowledgedRequest<DeleteRepositor
private String name;
DeleteRepositoryRequest() {
public DeleteRepositoryRequest() {
}
/**

View File

@ -36,7 +36,7 @@ public class GetRepositoriesRequest extends MasterNodeReadRequest<GetRepositorie
private String[] repositories = Strings.EMPTY_ARRAY;
GetRepositoriesRequest() {
public GetRepositoriesRequest() {
}
/**

View File

@ -55,7 +55,7 @@ public class PutRepositoryRequest extends AcknowledgedRequest<PutRepositoryReque
private Settings settings = EMPTY_SETTINGS;
PutRepositoryRequest() {
public PutRepositoryRequest() {
}
/**

View File

@ -37,7 +37,7 @@ public class VerifyRepositoryRequest extends AcknowledgedRequest<VerifyRepositor
private String name;
VerifyRepositoryRequest() {
public VerifyRepositoryRequest() {
}
/**

View File

@ -79,7 +79,7 @@ public class CreateSnapshotRequest extends MasterNodeRequest<CreateSnapshotReque
private boolean waitForCompletion;
CreateSnapshotRequest() {
public CreateSnapshotRequest() {
}
/**

View File

@ -41,7 +41,7 @@ public class GetSnapshotsRequest extends MasterNodeRequest<GetSnapshotsRequest>
private String[] snapshots = Strings.EMPTY_ARRAY;
GetSnapshotsRequest() {
public GetSnapshotsRequest() {
}
/**

View File

@ -64,7 +64,7 @@ public class RestoreSnapshotRequest extends MasterNodeRequest<RestoreSnapshotReq
private Settings indexSettings = EMPTY_SETTINGS;
private String[] ignoreIndexSettings = Strings.EMPTY_ARRAY;
RestoreSnapshotRequest() {
public RestoreSnapshotRequest() {
}
/**

View File

@ -137,7 +137,7 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
return true;
}
static class Request extends BaseNodesRequest<Request> {
public static class Request extends BaseNodesRequest<Request> {
private SnapshotId[] snapshotIds;
@ -203,11 +203,11 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction<Transpor
}
static class NodeRequest extends BaseNodeRequest {
public static class NodeRequest extends BaseNodeRequest {
private SnapshotId[] snapshotIds;
NodeRequest() {
public NodeRequest() {
}
NodeRequest(String nodeId, TransportNodesSnapshotsStatus.Request request) {

View File

@ -30,7 +30,7 @@ import java.io.IOException;
*/
public class ClusterStatsRequest extends BaseNodesRequest<ClusterStatsRequest> {
ClusterStatsRequest() {
public ClusterStatsRequest() {
}
/**

View File

@ -145,11 +145,11 @@ public class TransportClusterStatsAction extends TransportNodesAction<ClusterSta
return false;
}
static class ClusterStatsNodeRequest extends BaseNodeRequest {
public static class ClusterStatsNodeRequest extends BaseNodeRequest {
ClusterStatsRequest request;
ClusterStatsNodeRequest() {
public ClusterStatsNodeRequest() {
}
ClusterStatsNodeRequest(String nodeId, ClusterStatsRequest request) {

View File

@ -37,7 +37,7 @@ public class ClearIndicesCacheRequest extends BroadcastRequest<ClearIndicesCache
private String[] fields = null;
ClearIndicesCacheRequest() {
public ClearIndicesCacheRequest() {
}
public ClearIndicesCacheRequest(String... indices) {

View File

@ -39,7 +39,7 @@ public class CloseIndexRequest extends AcknowledgedRequest<CloseIndexRequest> im
private String[] indices;
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, false);
CloseIndexRequest() {
public CloseIndexRequest() {
}
/**

View File

@ -78,7 +78,7 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
private boolean updateAllTypes = false;
CreateIndexRequest() {
public CreateIndexRequest() {
}
/**

View File

@ -44,7 +44,7 @@ public class DeleteIndexRequest extends MasterNodeRequest<DeleteIndexRequest> im
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true);
private TimeValue timeout = AcknowledgedRequest.DEFAULT_ACK_TIMEOUT;
DeleteIndexRequest() {
public DeleteIndexRequest() {
}
/**

View File

@ -37,7 +37,7 @@ public class IndicesExistsRequest extends MasterNodeReadRequest<IndicesExistsReq
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, true);
// for serialization
IndicesExistsRequest() {
public IndicesExistsRequest() {
}

View File

@ -38,7 +38,7 @@ public class TypesExistsRequest extends MasterNodeReadRequest<TypesExistsRequest
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();
TypesExistsRequest() {
public TypesExistsRequest() {
}
public TypesExistsRequest(String[] indices, String... types) {

View File

@ -42,7 +42,7 @@ public class FlushRequest extends BroadcastRequest<FlushRequest> {
private boolean force = false;
private boolean waitIfOngoing = false;
FlushRequest() {
public FlushRequest() {
}
/**

View File

@ -29,7 +29,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import java.io.IOException;
class GetFieldMappingsIndexRequest extends SingleShardRequest<GetFieldMappingsIndexRequest> {
public class GetFieldMappingsIndexRequest extends SingleShardRequest<GetFieldMappingsIndexRequest> {
private boolean probablySingleFieldRequest;
private boolean includeDefaults;
@ -38,7 +38,7 @@ class GetFieldMappingsIndexRequest extends SingleShardRequest<GetFieldMappingsIn
private OriginalIndices originalIndices;
GetFieldMappingsIndexRequest() {
public GetFieldMappingsIndexRequest() {
}
GetFieldMappingsIndexRequest(GetFieldMappingsRequest other, String index, boolean probablySingleFieldRequest) {

View File

@ -65,7 +65,7 @@ public class PutMappingRequest extends AcknowledgedRequest<PutMappingRequest> im
private boolean updateAllTypes = false;
PutMappingRequest() {
public PutMappingRequest() {
}
/**

View File

@ -39,7 +39,7 @@ public class OpenIndexRequest extends AcknowledgedRequest<OpenIndexRequest> impl
private String[] indices;
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, false, true);
OpenIndexRequest() {
public OpenIndexRequest() {
}
/**

View File

@ -33,7 +33,7 @@ import org.elasticsearch.action.support.broadcast.BroadcastRequest;
*/
public class RefreshRequest extends BroadcastRequest<RefreshRequest> {
RefreshRequest() {
public RefreshRequest() {
}
/**

View File

@ -48,7 +48,7 @@ public class UpdateSettingsRequest extends AcknowledgedRequest<UpdateSettingsReq
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, true);
private Settings settings = EMPTY_SETTINGS;
UpdateSettingsRequest() {
public UpdateSettingsRequest() {
}
/**

View File

@ -46,7 +46,7 @@ public class IndicesShardStoresRequest extends MasterNodeReadRequest<IndicesShar
this.indices = indices;
}
IndicesShardStoresRequest() {
public IndicesShardStoresRequest() {
}
/**

View File

@ -74,7 +74,7 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
private Map<String, IndexMetaData.Custom> customs = new HashMap<>();
PutIndexTemplateRequest() {
public PutIndexTemplateRequest() {
}
/**

View File

@ -30,11 +30,11 @@ import java.io.IOException;
/**
*
*/
final class ShardUpgradeRequest extends BroadcastShardRequest {
public final class ShardUpgradeRequest extends BroadcastShardRequest {
private UpgradeRequest request = new UpgradeRequest();
ShardUpgradeRequest() {
public ShardUpgradeRequest() {
}
ShardUpgradeRequest(ShardId shardId, UpgradeRequest request) {

View File

@ -39,7 +39,7 @@ public class UpgradeSettingsRequest extends AcknowledgedRequest<UpgradeSettingsR
private Map<String, Tuple<Version, String>> versions;
UpgradeSettingsRequest() {
public UpgradeSettingsRequest() {
}
/**

View File

@ -32,7 +32,7 @@ import java.io.IOException;
/**
* Internal validate request executed directly against a specific index shard.
*/
class ShardValidateQueryRequest extends BroadcastShardRequest {
public class ShardValidateQueryRequest extends BroadcastShardRequest {
private BytesReference source;
private String[] types = Strings.EMPTY_ARRAY;
@ -43,7 +43,7 @@ class ShardValidateQueryRequest extends BroadcastShardRequest {
@Nullable
private String[] filteringAliases;
ShardValidateQueryRequest() {
public ShardValidateQueryRequest() {
}

View File

@ -55,7 +55,7 @@ public class ValidateQueryRequest extends BroadcastRequest<ValidateQueryRequest>
long nowInMillis;
ValidateQueryRequest() {
public ValidateQueryRequest() {
this(Strings.EMPTY_ARRAY);
}

View File

@ -38,7 +38,7 @@ public class TransportRenderSearchTemplateAction extends HandledTransportAction<
private final ScriptService scriptService;
@Inject
protected TransportRenderSearchTemplateAction(ScriptService scriptService, Settings settings, ThreadPool threadPool,
public TransportRenderSearchTemplateAction(ScriptService scriptService, Settings settings, ThreadPool threadPool,
TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, RenderSearchTemplateAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, RenderSearchTemplateRequest.class);
this.scriptService = scriptService;

View File

@ -42,7 +42,7 @@ public class DeleteWarmerRequest extends AcknowledgedRequest<DeleteWarmerRequest
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, false);
private String[] indices = Strings.EMPTY_ARRAY;
DeleteWarmerRequest() {
public DeleteWarmerRequest() {
}
/**

View File

@ -44,7 +44,7 @@ public class PutWarmerRequest extends AcknowledgedRequest<PutWarmerRequest> impl
private SearchRequest searchRequest;
PutWarmerRequest() {
public PutWarmerRequest() {
}
/**

View File

@ -37,7 +37,7 @@ public class BulkShardRequest extends ReplicationRequest<BulkShardRequest> {
private boolean refresh;
BulkShardRequest() {
public BulkShardRequest() {
}
BulkShardRequest(BulkRequest bulkRequest, String index, int shardId, boolean refresh, BulkItemRequest[] items) {

View File

@ -55,7 +55,7 @@ public class ExistsRequest extends BroadcastRequest<ExistsRequest> {
long nowInMillis;
ExistsRequest() {
public ExistsRequest() {
}
/**

View File

@ -29,7 +29,7 @@ import org.elasticsearch.index.shard.ShardId;
import java.io.IOException;
class ShardExistsRequest extends BroadcastShardRequest {
public class ShardExistsRequest extends BroadcastShardRequest {
private float minScore;
@ -42,7 +42,7 @@ class ShardExistsRequest extends BroadcastShardRequest {
@Nullable
private String[] filteringAliases;
ShardExistsRequest() {
public ShardExistsRequest() {
}
ShardExistsRequest(ShardId shardId, @Nullable String[] filteringAliases, ExistsRequest request) {

View File

@ -49,7 +49,7 @@ public class ExplainRequest extends SingleShardRequest<ExplainRequest> {
long nowInMillis;
ExplainRequest() {
public ExplainRequest() {
}
public ExplainRequest(String index, String type, String id) {

View File

@ -63,7 +63,7 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
private long version = Versions.MATCH_ANY;
private boolean ignoreErrorsOnGeneratedFields;
GetRequest() {
public GetRequest() {
type = "_all";
}

View File

@ -40,7 +40,7 @@ public class MultiGetShardRequest extends SingleShardRequest<MultiGetShardReques
IntArrayList locations;
List<MultiGetRequest.Item> items;
MultiGetShardRequest() {
public MultiGetShardRequest() {
}

View File

@ -39,7 +39,7 @@ public class PercolateShardRequest extends BroadcastShardRequest {
private int numberOfShards;
private long startTime;
PercolateShardRequest() {
public PercolateShardRequest() {
}
PercolateShardRequest(ShardId shardId, int numberOfShards, PercolateRequest request) {

View File

@ -118,7 +118,7 @@ public class TransportShardMultiPercolateAction extends TransportSingleShardActi
private String preference;
private List<Item> items;
Request() {
public Request() {
}
Request(MultiPercolateRequest multiPercolateRequest, String concreteIndex, int shardId, String preference) {

View File

@ -30,11 +30,11 @@ import java.io.IOException;
/**
* Internal suggest request executed directly against a specific index shard.
*/
final class ShardSuggestRequest extends BroadcastShardRequest {
public final class ShardSuggestRequest extends BroadcastShardRequest {
private BytesReference suggestSource;
ShardSuggestRequest() {
public ShardSuggestRequest() {
}
ShardSuggestRequest(ShardId shardId, SuggestRequest request) {

View File

@ -58,7 +58,7 @@ public final class SuggestRequest extends BroadcastRequest<SuggestRequest> {
private BytesReference suggestSource;
SuggestRequest() {
public SuggestRequest() {
}
/**

View File

@ -38,7 +38,7 @@ public abstract class BroadcastShardRequest extends TransportRequest implements
protected OriginalIndices originalIndices;
protected BroadcastShardRequest() {
public BroadcastShardRequest() {
}
protected BroadcastShardRequest(ShardId shardId, BroadcastRequest request) {

View File

@ -405,14 +405,14 @@ public abstract class TransportBroadcastByNodeAction<Request extends BroadcastRe
}
}
protected class NodeRequest extends TransportRequest implements IndicesRequest {
public class NodeRequest extends TransportRequest implements IndicesRequest {
private String nodeId;
private List<ShardRouting> shards;
protected Request indicesLevelRequest;
protected NodeRequest() {
public NodeRequest() {
}
public NodeRequest(String nodeId, Request request, List<ShardRouting> shards) {

View File

@ -32,7 +32,7 @@ public abstract class BaseNodeRequest extends TransportRequest {
private String nodeId;
protected BaseNodeRequest() {
public BaseNodeRequest() {
}

View File

@ -49,7 +49,7 @@ public abstract class SingleShardRequest<T extends SingleShardRequest> extends A
ShardId internalShardId;
private boolean threadedOperation = true;
protected SingleShardRequest() {
public SingleShardRequest() {
}
protected SingleShardRequest(String index) {

View File

@ -37,7 +37,7 @@ public class MultiTermVectorsShardRequest extends SingleShardRequest<MultiTermVe
IntArrayList locations;
List<TermVectorsRequest> requests;
MultiTermVectorsShardRequest() {
public MultiTermVectorsShardRequest() {
}

View File

@ -44,7 +44,7 @@ public class DfsOnlyRequest extends BroadcastRequest<DfsOnlyRequest> {
long nowInMillis;
DfsOnlyRequest() {
public DfsOnlyRequest() {
}

View File

@ -29,11 +29,11 @@ import org.elasticsearch.search.internal.ShardSearchTransportRequest;
import java.io.IOException;
class ShardDfsOnlyRequest extends BroadcastShardRequest {
public class ShardDfsOnlyRequest extends BroadcastShardRequest {
private ShardSearchTransportRequest shardSearchRequest = new ShardSearchTransportRequest();
ShardDfsOnlyRequest() {
public ShardDfsOnlyRequest() {
}

View File

@ -133,12 +133,12 @@ public class NodeIndexDeletedAction extends AbstractComponent {
}
}
static class NodeIndexDeletedMessage extends TransportRequest {
public static class NodeIndexDeletedMessage extends TransportRequest {
String index;
String nodeId;
NodeIndexDeletedMessage() {
public NodeIndexDeletedMessage() {
}
NodeIndexDeletedMessage(String index, String nodeId) {
@ -161,12 +161,12 @@ public class NodeIndexDeletedAction extends AbstractComponent {
}
}
static class NodeIndexStoreDeletedMessage extends TransportRequest {
public static class NodeIndexStoreDeletedMessage extends TransportRequest {
String index;
String nodeId;
NodeIndexStoreDeletedMessage() {
public NodeIndexStoreDeletedMessage() {
}
NodeIndexStoreDeletedMessage(String index, String nodeId) {

View File

@ -79,7 +79,7 @@ public class NodeMappingRefreshAction extends AbstractComponent {
private String[] types;
private String nodeId;
NodeMappingRefreshRequest() {
public NodeMappingRefreshRequest() {
}
public NodeMappingRefreshRequest(String index, String indexUUID, String[] types, String nodeId) {

View File

@ -244,7 +244,7 @@ public class ShardStateAction extends AbstractComponent {
}
}
static class ShardRoutingEntry extends TransportRequest {
public static class ShardRoutingEntry extends TransportRequest {
ShardRouting shardRouting;
String indexUUID = IndexMetaData.INDEX_UUID_NA_VALUE;
@ -253,7 +253,7 @@ public class ShardStateAction extends AbstractComponent {
volatile boolean processed; // state field, no need to serialize
ShardRoutingEntry() {
public ShardRoutingEntry() {
}
ShardRoutingEntry(ShardRouting shardRouting, String indexUUID, String message, @Nullable Throwable failure) {

View File

@ -43,12 +43,6 @@ class DefaultConstructionProxyFactory<T> implements ConstructionProxyFactory<T>
@SuppressWarnings("unchecked") // the injection point is for a constructor of T
final Constructor<T> constructor = (Constructor<T>) injectionPoint.getMember();
// Use FastConstructor if the constructor is public.
if (Modifier.isPublic(constructor.getModifiers())) {
} else {
constructor.setAccessible(true);
}
return new ConstructionProxy<T>() {
@Override
public T newInstance(Object... arguments) throws InvocationTargetException {
@ -57,7 +51,7 @@ class DefaultConstructionProxyFactory<T> implements ConstructionProxyFactory<T>
} catch (InstantiationException e) {
throw new AssertionError(e); // shouldn't happen, we know this is a concrete type
} catch (IllegalAccessException e) {
throw new AssertionError(e); // a security manager is blocking us, we're hosed
throw new AssertionError("Wrong access modifiers on " + constructor, e); // a security manager is blocking us, we're hosed
}
}

View File

@ -39,9 +39,6 @@ class SingleFieldInjector implements SingleMemberInjector {
this.injectionPoint = injectionPoint;
this.field = (Field) injectionPoint.getMember();
this.dependency = injectionPoint.getDependencies().get(0);
// Ewwwww...
field.setAccessible(true);
factory = injector.getInternalFactory(dependency.getKey(), errors);
}

View File

@ -49,10 +49,6 @@ class SingleMethodInjector implements SingleMemberInjector {
if (!Modifier.isPrivate(modifiers) && !Modifier.isProtected(modifiers)) {
}
if (!Modifier.isPublic(modifiers)) {
method.setAccessible(true);
}
return new MethodInvoker() {
@Override
public Object invoke(Object target, Object... parameters)

View File

@ -88,7 +88,6 @@ class AssistedConstructor<T> {
* supplied arguments.
*/
public T newInstance(Object[] args) throws Throwable {
constructor.setAccessible(true);
try {
return constructor.newInstance(args);
} catch (InvocationTargetException e) {

View File

@ -53,7 +53,7 @@ import static org.elasticsearch.common.inject.internal.Annotations.getKey;
* @author jessewilson@google.com (Jesse Wilson)
* @author dtm@google.com (Daniel Martin)
*/
final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {
public final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {
/**
* if a factory method parameter isn't annotated, it gets this annotation.
@ -173,7 +173,7 @@ final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {
* all factory methods will be able to build the target types.
*/
@Inject
void initialize(Injector injector) {
public void initialize(Injector injector) {
if (this.injector != null) {
throw new ConfigurationException(Collections.singletonList(new Message(FactoryProvider2.class,
"Factories.create() factories may only be used in one Injector!")));

View File

@ -54,8 +54,6 @@ public class ProviderMethod<T> implements ProviderWithDependencies<T> {
this.method = method;
this.parameterProviders = parameterProviders;
this.exposed = method.getAnnotation(Exposed.class) != null;
method.setAccessible(true);
}
public Key<T> getKey() {

View File

@ -17,6 +17,7 @@
package org.elasticsearch.common.inject.multibindings;
import com.google.common.collect.ImmutableSet;
import org.elasticsearch.common.inject.*;
import org.elasticsearch.common.inject.binder.LinkedBindingBuilder;
import org.elasticsearch.common.inject.multibindings.Multibinder.RealMultibinder;
@ -227,7 +228,7 @@ public abstract class MapBinder<K, V> {
* <p/>
* <p>We use a subclass to hide 'implements Module' from the public API.
*/
private static final class RealMapBinder<K, V> extends MapBinder<K, V> implements Module {
public static final class RealMapBinder<K, V> extends MapBinder<K, V> implements Module {
private final TypeLiteral<V> valueType;
private final Key<Map<K, V>> mapKey;
private final Key<Map<K, Provider<V>>> providerMapKey;
@ -260,8 +261,48 @@ public abstract class MapBinder<K, V> {
binder.getProvider(valueKey)));
return binder.bind(valueKey);
}
public static class MapBinderProviderWithDependencies<K,V> implements ProviderWithDependencies<Map<K, Provider<V>>> {
private Map<K, Provider<V>> providerMap;
@SuppressWarnings("rawtypes") // code is silly stupid with generics
private final RealMapBinder binder;
private final Set<Dependency<?>> dependencies;
private final Provider<Set<Entry<K, Provider<V>>>> provider;
@SuppressWarnings("rawtypes") // code is silly stupid with generics
MapBinderProviderWithDependencies(RealMapBinder binder, Set<Dependency<?>> dependencies, Provider<Set<Entry<K, Provider<V>>>> provider) {
this.binder = binder;
this.dependencies = dependencies;
this.provider = provider;
}
@Override
@SuppressWarnings({"unchecked", "unused"}) // code is silly stupid with generics
@Inject
public void initialize() {
binder.binder = null;
Map<K, Provider<V>> providerMapMutable = new LinkedHashMap<>();
for (Entry<K, Provider<V>> entry : provider.get()) {
Multibinder.checkConfiguration(providerMapMutable.put(entry.getKey(), entry.getValue()) == null,
"Map injection failed due to duplicated key \"%s\"", entry.getKey());
}
providerMap = Collections.unmodifiableMap(providerMapMutable);
}
@Override
public Map<K, Provider<V>> get() {
return providerMap;
}
@Override
public Set<Dependency<?>> getDependencies() {
return dependencies;
}
}
@Override @SuppressWarnings({"rawtypes", "unchecked"}) // code is silly stupid with generics
public void configure(Binder binder) {
Multibinder.checkConfiguration(!isInitialized(), "MapBinder was already initialized");
@ -271,33 +312,7 @@ public abstract class MapBinder<K, V> {
// binds a Map<K, Provider<V>> from a collection of Map<Entry<K, Provider<V>>
final Provider<Set<Entry<K, Provider<V>>>> entrySetProvider = binder
.getProvider(entrySetBinder.getSetKey());
binder.bind(providerMapKey).toProvider(new ProviderWithDependencies<Map<K, Provider<V>>>() {
private Map<K, Provider<V>> providerMap;
@SuppressWarnings("unused")
@Inject
void initialize() {
RealMapBinder.this.binder = null;
Map<K, Provider<V>> providerMapMutable = new LinkedHashMap<>();
for (Entry<K, Provider<V>> entry : entrySetProvider.get()) {
Multibinder.checkConfiguration(providerMapMutable.put(entry.getKey(), entry.getValue()) == null,
"Map injection failed due to duplicated key \"%s\"", entry.getKey());
}
providerMap = Collections.unmodifiableMap(providerMapMutable);
}
@Override
public Map<K, Provider<V>> get() {
return providerMap;
}
@Override
public Set<Dependency<?>> getDependencies() {
return dependencies;
}
});
binder.bind(providerMapKey).toProvider(new MapBinderProviderWithDependencies(RealMapBinder.this, dependencies, entrySetProvider));
final Provider<Map<K, Provider<V>>> mapProvider = binder.getProvider(providerMapKey);
binder.bind(mapKey).toProvider(new ProviderWithDependencies<Map<K, V>>() {

View File

@ -193,7 +193,7 @@ public abstract class Multibinder<T> {
* <p>We use a subclass to hide 'implements Module, Provider' from the public
* API.
*/
static final class RealMultibinder<T> extends Multibinder<T>
public static final class RealMultibinder<T> extends Multibinder<T>
implements Module, Provider<Set<T>>, HasDependencies {
private final TypeLiteral<T> elementType;
@ -236,7 +236,7 @@ public abstract class Multibinder<T> {
* contents are only evaluated when get() is invoked.
*/
@Inject
void initialize(Injector injector) {
public void initialize(Injector injector) {
providers = new ArrayList<>();
List<Dependency<?>> dependencies = new ArrayList<>();
for (Binding<?> entry : injector.findBindingsByType(elementType)) {

View File

@ -1131,7 +1131,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
return rejoinOnMasterGone;
}
static class RejoinClusterRequest extends TransportRequest {
public static class RejoinClusterRequest extends TransportRequest {
private String fromNodeId;
@ -1139,7 +1139,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
this.fromNodeId = fromNodeId;
}
RejoinClusterRequest() {
public RejoinClusterRequest() {
}
@Override

View File

@ -386,14 +386,14 @@ public class MasterFaultDetection extends FaultDetection {
}
private static class MasterPingRequest extends TransportRequest {
public static class MasterPingRequest extends TransportRequest {
private String nodeId;
private String masterNodeId;
private ClusterName clusterName;
private MasterPingRequest() {
public MasterPingRequest() {
}
private MasterPingRequest(String nodeId, String masterNodeId, ClusterName clusterName) {

View File

@ -271,7 +271,7 @@ public class NodesFaultDetection extends FaultDetection {
private long clusterStateVersion = ClusterState.UNKNOWN_VERSION;
PingRequest() {
public PingRequest() {
}
PingRequest(String nodeId, ClusterName clusterName, DiscoveryNode masterNode, long clusterStateVersion) {

View File

@ -105,11 +105,11 @@ public class MembershipAction extends AbstractComponent {
.txGet(timeout.millis(), TimeUnit.MILLISECONDS);
}
static class JoinRequest extends TransportRequest {
public static class JoinRequest extends TransportRequest {
DiscoveryNode node;
private JoinRequest() {
public JoinRequest() {
}
private JoinRequest(DiscoveryNode node) {
@ -156,9 +156,9 @@ public class MembershipAction extends AbstractComponent {
}
}
static class ValidateJoinRequest extends TransportRequest {
public static class ValidateJoinRequest extends TransportRequest {
ValidateJoinRequest() {
public ValidateJoinRequest() {
}
}
@ -171,11 +171,11 @@ public class MembershipAction extends AbstractComponent {
}
}
static class LeaveRequest extends TransportRequest {
public static class LeaveRequest extends TransportRequest {
private DiscoveryNode node;
private LeaveRequest() {
public LeaveRequest() {
}
private LeaveRequest(DiscoveryNode node) {

View File

@ -523,13 +523,13 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
}
}
static class UnicastPingRequest extends TransportRequest {
public static class UnicastPingRequest extends TransportRequest {
int id;
TimeValue timeout;
PingResponse pingResponse;
UnicastPingRequest() {
public UnicastPingRequest() {
}
@Override

View File

@ -188,12 +188,12 @@ public class LocalAllocateDangledIndices extends AbstractComponent {
}
}
static class AllocateDangledRequest extends TransportRequest {
public static class AllocateDangledRequest extends TransportRequest {
DiscoveryNode fromNode;
IndexMetaData[] indices;
AllocateDangledRequest() {
public AllocateDangledRequest() {
}
AllocateDangledRequest(DiscoveryNode fromNode, IndexMetaData[] indices) {

View File

@ -120,7 +120,7 @@ public class TransportNodesListGatewayMetaState extends TransportNodesAction<Tra
return true;
}
static class Request extends BaseNodesRequest<Request> {
public static class Request extends BaseNodesRequest<Request> {
public Request() {
}
@ -177,9 +177,9 @@ public class TransportNodesListGatewayMetaState extends TransportNodesAction<Tra
}
static class NodeRequest extends BaseNodeRequest {
public static class NodeRequest extends BaseNodeRequest {
NodeRequest() {
public NodeRequest() {
}
NodeRequest(String nodeId, TransportNodesListGatewayMetaState.Request request) {

View File

@ -160,7 +160,7 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesAction
return true;
}
static class Request extends BaseNodesRequest<Request> {
public static class Request extends BaseNodesRequest<Request> {
private ShardId shardId;
private String indexUUID;
@ -233,12 +233,12 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesAction
}
static class NodeRequest extends BaseNodeRequest {
public static class NodeRequest extends BaseNodeRequest {
private ShardId shardId;
private String indexUUID;
NodeRequest() {
public NodeRequest() {
}
NodeRequest(String nodeId, TransportNodesListGatewayStartedShards.Request request) {
@ -275,7 +275,7 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesAction
private long version = -1;
private Throwable storeException = null;
NodeGatewayStartedShards() {
public NodeGatewayStartedShards() {
}
public NodeGatewayStartedShards(DiscoveryNode node, long version) {
this(node, version, null);

View File

@ -435,10 +435,10 @@ public class SyncedFlushService extends AbstractComponent {
return new InFlightOpsResponse(opCount);
}
final static class PreSyncedFlushRequest extends TransportRequest {
public final static class PreSyncedFlushRequest extends TransportRequest {
private ShardId shardId;
PreSyncedFlushRequest() {
public PreSyncedFlushRequest() {
}
public PreSyncedFlushRequest(ShardId shardId) {
@ -500,7 +500,7 @@ public class SyncedFlushService extends AbstractComponent {
}
}
static final class SyncedFlushRequest extends TransportRequest {
public static final class SyncedFlushRequest extends TransportRequest {
private String syncId;
private Engine.CommitId expectedCommitId;
@ -600,7 +600,7 @@ public class SyncedFlushService extends AbstractComponent {
}
static final class InFlightOpsRequest extends TransportRequest {
public static final class InFlightOpsRequest extends TransportRequest {
private ShardId shardId;

View File

@ -30,7 +30,7 @@ import java.io.IOException;
/**
*
*/
class RecoveryCleanFilesRequest extends TransportRequest {
public class RecoveryCleanFilesRequest extends TransportRequest {
private long recoveryId;
private ShardId shardId;
@ -38,7 +38,7 @@ class RecoveryCleanFilesRequest extends TransportRequest {
private Store.MetadataSnapshot snapshotFiles;
private int totalTranslogOps = RecoveryState.Translog.UNKNOWN;
RecoveryCleanFilesRequest() {
public RecoveryCleanFilesRequest() {
}
RecoveryCleanFilesRequest(long recoveryId, ShardId shardId, Store.MetadataSnapshot snapshotFiles, int totalTranslogOps) {

View File

@ -34,7 +34,7 @@ import java.io.IOException;
/**
*
*/
public final class RecoveryFileChunkRequest extends TransportRequest { // public for testing
public final class RecoveryFileChunkRequest extends TransportRequest {
private boolean lastChunk;
private long recoveryId;
private ShardId shardId;
@ -45,7 +45,7 @@ public final class RecoveryFileChunkRequest extends TransportRequest { // publi
private int totalTranslogOps;
RecoveryFileChunkRequest() {
public RecoveryFileChunkRequest() {
}
public RecoveryFileChunkRequest(long recoveryId, ShardId shardId, StoreFileMetaData metaData, long position, BytesReference content,

View File

@ -31,7 +31,7 @@ import java.util.List;
/**
*
*/
class RecoveryFilesInfoRequest extends TransportRequest {
public class RecoveryFilesInfoRequest extends TransportRequest {
private long recoveryId;
private ShardId shardId;
@ -43,7 +43,7 @@ class RecoveryFilesInfoRequest extends TransportRequest {
int totalTranslogOps;
RecoveryFilesInfoRequest() {
public RecoveryFilesInfoRequest() {
}
RecoveryFilesInfoRequest(long recoveryId, ShardId shardId, List<String> phase1FileNames, List<Long> phase1FileSizes,

View File

@ -29,13 +29,13 @@ import java.io.IOException;
/**
*
*/
class RecoveryFinalizeRecoveryRequest extends TransportRequest {
public class RecoveryFinalizeRecoveryRequest extends TransportRequest {
private long recoveryId;
private ShardId shardId;
RecoveryFinalizeRecoveryRequest() {
public RecoveryFinalizeRecoveryRequest() {
}
RecoveryFinalizeRecoveryRequest(long recoveryId, ShardId shardId) {

View File

@ -29,13 +29,13 @@ import java.io.IOException;
/**
*
*/
class RecoveryPrepareForTranslogOperationsRequest extends TransportRequest {
public class RecoveryPrepareForTranslogOperationsRequest extends TransportRequest {
private long recoveryId;
private ShardId shardId;
private int totalTranslogOps = RecoveryState.Translog.UNKNOWN;
RecoveryPrepareForTranslogOperationsRequest() {
public RecoveryPrepareForTranslogOperationsRequest() {
}
RecoveryPrepareForTranslogOperationsRequest(long recoveryId, ShardId shardId, int totalTranslogOps) {

View File

@ -31,14 +31,14 @@ import java.util.List;
/**
*
*/
class RecoveryTranslogOperationsRequest extends TransportRequest {
public class RecoveryTranslogOperationsRequest extends TransportRequest {
private long recoveryId;
private ShardId shardId;
private List<Translog.Operation> operations;
private int totalTranslogOps = RecoveryState.Translog.UNKNOWN;
RecoveryTranslogOperationsRequest() {
public RecoveryTranslogOperationsRequest() {
}
RecoveryTranslogOperationsRequest(long recoveryId, ShardId shardId, List<Translog.Operation> operations, int totalTranslogOps) {

View File

@ -47,7 +47,7 @@ public class StartRecoveryRequest extends TransportRequest {
private RecoveryState.Type recoveryType;
StartRecoveryRequest() {
public StartRecoveryRequest() {
}
/**

View File

@ -396,13 +396,13 @@ public class IndicesStore extends AbstractComponent implements ClusterStateListe
}
}
private static class ShardActiveRequest extends TransportRequest {
public static class ShardActiveRequest extends TransportRequest {
protected TimeValue timeout = null;
private ClusterName clusterName;
private String indexUUID;
private ShardId shardId;
ShardActiveRequest() {
public ShardActiveRequest() {
}
ShardActiveRequest(ClusterName clusterName, String indexUUID, ShardId shardId, TimeValue timeout) {

View File

@ -258,7 +258,7 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesAction<T
}
static class Request extends BaseNodesRequest<Request> {
public static class Request extends BaseNodesRequest<Request> {
private ShardId shardId;
@ -331,13 +331,13 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesAction<T
}
static class NodeRequest extends BaseNodeRequest {
public static class NodeRequest extends BaseNodeRequest {
private ShardId shardId;
private boolean unallocated;
NodeRequest() {
public NodeRequest() {
}
NodeRequest(String nodeId, TransportNodesListShardStoreMetaData.Request request) {

View File

@ -157,12 +157,10 @@ public class OsProbe {
*/
private static Method getMethod(String methodName) {
try {
Method method = osMxBean.getClass().getMethod(methodName);
method.setAccessible(true);
return method;
return Class.forName("com.sun.management.OperatingSystemMXBean").getMethod(methodName);
} catch (Throwable t) {
// not available
return null;
}
return null;
}
}

View File

@ -227,7 +227,6 @@ public class OsStats implements Streamable, ToXContent {
}
}
// TODO: if values are -1, this should return -1 to show its unsupported?
private static short calculatePercentage(long used, long max) {
return max <= 0 ? 0 : (short) (Math.round((100d * used) / max));
}

View File

@ -38,8 +38,8 @@ public class ProcessProbe {
private static final Method getCommittedVirtualMemorySize;
static {
getMaxFileDescriptorCountField = getMethod("getMaxFileDescriptorCount");
getOpenFileDescriptorCountField = getMethod("getOpenFileDescriptorCount");
getMaxFileDescriptorCountField = getUnixMethod("getMaxFileDescriptorCount");
getOpenFileDescriptorCountField = getUnixMethod("getOpenFileDescriptorCount");
getProcessCpuLoad = getMethod("getProcessCpuLoad");
getProcessCpuTime = getMethod("getProcessCpuTime");
getCommittedVirtualMemorySize = getMethod("getCommittedVirtualMemorySize");
@ -163,12 +163,23 @@ public class ProcessProbe {
*/
private static Method getMethod(String methodName) {
try {
Method method = osMxBean.getClass().getDeclaredMethod(methodName);
method.setAccessible(true);
return method;
return Class.forName("com.sun.management.OperatingSystemMXBean").getMethod(methodName);
} catch (Throwable t) {
// not available
return null;
}
}
/**
* Returns a given method of the UnixOperatingSystemMXBean,
* or null if the method is not found or unavailable.
*/
private static Method getUnixMethod(String methodName) {
try {
return Class.forName("com.sun.management.UnixOperatingSystemMXBean").getMethod(methodName);
} catch (Throwable t) {
// not available
return null;
}
return null;
}
}

View File

@ -121,12 +121,12 @@ public class VerifyNodeRepositoryAction extends AbstractComponent {
blobStoreIndexShardRepository.verify(verificationToken);
}
static class VerifyNodeRepositoryRequest extends TransportRequest {
public static class VerifyNodeRepositoryRequest extends TransportRequest {
private String repository;
private String verificationToken;
VerifyNodeRepositoryRequest() {
public VerifyNodeRepositoryRequest() {
}
VerifyNodeRepositoryRequest(String repository, String verificationToken) {

View File

@ -31,7 +31,7 @@ import org.elasticsearch.repositories.RepositoryName;
public class URLIndexShardRepository extends BlobStoreIndexShardRepository {
@Inject
URLIndexShardRepository(Settings settings, RepositoryName repositoryName, IndicesService indicesService, ClusterService clusterService) {
public URLIndexShardRepository(Settings settings, RepositoryName repositoryName, IndicesService indicesService, ClusterService clusterService) {
super(settings, repositoryName, indicesService, clusterService);
}

View File

@ -41,7 +41,7 @@ import static org.elasticsearch.rest.RestRequest.Method.GET;
public class RestCountAction extends AbstractCatAction {
@Inject
protected RestCountAction(Settings settings, RestController restController, RestController controller, Client client) {
public RestCountAction(Settings settings, RestController restController, RestController controller, Client client) {
super(settings, controller, client);
restController.registerHandler(GET, "/_cat/count", this);
restController.registerHandler(GET, "/_cat/count/{index}", this);

View File

@ -50,7 +50,7 @@ import static org.elasticsearch.rest.RestRequest.Method.GET;
public class RestRecoveryAction extends AbstractCatAction {
@Inject
protected RestRecoveryAction(Settings settings, RestController restController, RestController controller, Client client) {
public RestRecoveryAction(Settings settings, RestController restController, RestController controller, Client client) {
super(settings, controller, client);
restController.registerHandler(GET, "/_cat/recovery", this);
restController.registerHandler(GET, "/_cat/recovery/{index}", this);

View File

@ -205,10 +205,10 @@ public class SearchServiceTransportAction extends AbstractComponent {
});
}
static class ScrollFreeContextRequest extends TransportRequest {
public static class ScrollFreeContextRequest extends TransportRequest {
private long id;
ScrollFreeContextRequest() {
public ScrollFreeContextRequest() {
}
ScrollFreeContextRequest(ClearScrollRequest request, long id) {
@ -237,10 +237,10 @@ public class SearchServiceTransportAction extends AbstractComponent {
}
}
static class SearchFreeContextRequest extends ScrollFreeContextRequest implements IndicesRequest {
public static class SearchFreeContextRequest extends ScrollFreeContextRequest implements IndicesRequest {
private OriginalIndices originalIndices;
SearchFreeContextRequest() {
public SearchFreeContextRequest() {
}
SearchFreeContextRequest(SearchRequest request, long id) {
@ -313,9 +313,9 @@ public class SearchServiceTransportAction extends AbstractComponent {
}
}
static class ClearScrollContextsRequest extends TransportRequest {
public static class ClearScrollContextsRequest extends TransportRequest {
ClearScrollContextsRequest() {
public ClearScrollContextsRequest() {
}
ClearScrollContextsRequest(TransportRequest request) {

View File

@ -1036,14 +1036,14 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
/**
* Internal class that is used to send notifications about finished shard restore operations to master node
*/
static class UpdateIndexShardRestoreStatusRequest extends TransportRequest {
public static class UpdateIndexShardRestoreStatusRequest extends TransportRequest {
private SnapshotId snapshotId;
private ShardId shardId;
private ShardRestoreStatus status;
volatile boolean processed; // state field, no need to serialize
private UpdateIndexShardRestoreStatusRequest() {
public UpdateIndexShardRestoreStatusRequest() {
}

View File

@ -410,7 +410,7 @@ public class SnapshotShardsService extends AbstractLifecycleComponent<SnapshotSh
/**
* Internal request that is used to send changes in snapshot status to master
*/
private static class UpdateIndexShardSnapshotStatusRequest extends TransportRequest {
public static class UpdateIndexShardSnapshotStatusRequest extends TransportRequest {
private SnapshotId snapshotId;
private ShardId shardId;
private SnapshotsInProgress.ShardSnapshotStatus status;

View File

@ -81,12 +81,15 @@ public class RequestHandlerRegistry<Request extends TransportRequest> {
} catch (NoSuchMethodException e) {
throw new IllegalStateException("failed to create constructor (does it have a default constructor?) for request " + request, e);
}
this.requestConstructor.setAccessible(true);
}
@Override
public Request call() throws Exception {
return requestConstructor.newInstance();
try {
return requestConstructor.newInstance();
} catch (IllegalAccessException e) {
throw new IllegalStateException("Could not access '" + requestConstructor + "'. Implementations must be a public class and have a public no-arg ctor.", e);
}
}
}
}

View File

@ -36,7 +36,7 @@ public abstract class TransportRequest extends TransportMessage<TransportRequest
}
}
protected TransportRequest() {
public TransportRequest() {
}
protected TransportRequest(TransportRequest request) {

View File

@ -447,7 +447,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
void execute(String action, ActionResponse response, ActionListener listener, ActionFilterChain chain);
}
private static class TestRequest extends ActionRequest {
public static class TestRequest extends ActionRequest {
@Override
public ActionRequestValidationException validate() {
return null;

View File

@ -551,12 +551,12 @@ public class ShardReplicationTests extends ESTestCase {
};
}
static class Request extends ReplicationRequest<Request> {
public static class Request extends ReplicationRequest<Request> {
int shardId;
public AtomicBoolean processedOnPrimary = new AtomicBoolean();
public AtomicInteger processedOnReplicas = new AtomicInteger();
Request() {
public Request() {
}
Request(ShardId shardId) {

View File

@ -173,7 +173,7 @@ public class TransportClientNodesServiceTests extends ESTestCase {
}
}
private static class TestRequest extends TransportRequest {
public static class TestRequest extends TransportRequest {
}

Some files were not shown because too many files have changed in this diff Show More