Skip to content

Commit bbfcab5

Browse files
committed
Clean up misc IDE warns in the classes touched by the WFCORE-7273 work
Do this in a separate commit so the main commit doesn't have all this noise.
1 parent 2ad8055 commit bbfcab5

File tree

17 files changed

+184
-224
lines changed

17 files changed

+184
-224
lines changed

controller-client/src/main/java/org/jboss/as/controller/client/impl/AbstractModelControllerClient.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
*/
4444
public abstract class AbstractModelControllerClient implements ModelControllerClient, ManagementRequestHandlerFactory {
4545

46-
private static ManagementRequestHandler<ModelNode, OperationExecutionContext> MESSAGE_HANDLER = new HandleReportRequestHandler();
47-
private static ManagementRequestHandler<ModelNode, OperationExecutionContext> GET_INPUT_STREAM = new ReadAttachmentInputStreamRequestHandler();
46+
private static final ManagementRequestHandler<ModelNode, OperationExecutionContext> MESSAGE_HANDLER = new HandleReportRequestHandler();
47+
private static final ManagementRequestHandler<ModelNode, OperationExecutionContext> GET_INPUT_STREAM = new ReadAttachmentInputStreamRequestHandler();
4848

4949
private static final OperationMessageHandler NO_OP_HANDLER = OperationMessageHandler.DISCARD;
5050

@@ -151,7 +151,7 @@ private static ModelNode responseNodeOnly(OperationResponse or) throws IOExcepti
151151
* @throws IOException
152152
*/
153153
private AsyncFuture<OperationResponse> execute(final OperationExecutionContext executionContext) throws IOException {
154-
return executeRequest(new AbstractManagementRequest<OperationResponse, OperationExecutionContext>() {
154+
return executeRequest(new AbstractManagementRequest<>() {
155155

156156
@Override
157157
public byte getOperationType() {
@@ -194,18 +194,18 @@ public void handleRequest(final DataInput input, final ActiveOperation.ResultHan
194194
// Read the inputStream index
195195
expectHeader(input, ModelControllerProtocol.PARAM_INPUTSTREAM_INDEX);
196196
final int index = input.readInt();
197-
context.executeAsync(new ManagementRequestContext.AsyncTask<OperationExecutionContext>() {
197+
context.executeAsync(new ManagementRequestContext.AsyncTask<>() {
198198
@Override
199-
public void execute(final ManagementRequestContext<OperationExecutionContext> context) throws Exception {
200-
final OperationExecutionContext exec = context.getAttachment();
201-
final ManagementRequestHeader header = ManagementRequestHeader.class.cast(context.getRequestHeader());
199+
public void execute(final ManagementRequestContext<OperationExecutionContext> taskContext) throws Exception {
200+
final OperationExecutionContext exec = taskContext.getAttachment();
201+
final ManagementRequestHeader header = (ManagementRequestHeader) taskContext.getRequestHeader();
202202
final ManagementResponseHeader response = new ManagementResponseHeader(header.getVersion(), header.getRequestId(), null);
203203
final InputStreamEntry entry = exec.getStream(index);
204204
synchronized (entry) {
205205
// Initialize the stream entry
206206
final int size = entry.initialize();
207207
try {
208-
final FlushableDataOutput output = context.writeMessage(response);
208+
final FlushableDataOutput output = taskContext.writeMessage(response);
209209
try {
210210
output.writeByte(ModelControllerProtocol.PARAM_INPUTSTREAM_LENGTH);
211211
output.writeInt(size);
@@ -245,7 +245,7 @@ public void handleRequest(final DataInput input, final ActiveOperation.ResultHan
245245

246246
}
247247

248-
protected AsyncFuture<OperationResponse> executeRequest(final ManagementRequest<OperationResponse, OperationExecutionContext> request, final OperationExecutionContext attachment) throws IOException {
248+
AsyncFuture<OperationResponse> executeRequest(final ManagementRequest<OperationResponse, OperationExecutionContext> request, final OperationExecutionContext attachment) throws IOException {
249249
final ActiveOperation<OperationResponse, OperationExecutionContext> support = getChannelAssociation().executeRequest(request, attachment, attachment);
250250
return new DelegatingCancellableAsyncFuture(support.getResult(), support.getOperationId());
251251
}
@@ -350,12 +350,12 @@ public byte getOperationType() {
350350
}
351351

352352
@Override
353-
protected void sendRequest(ActiveOperation.ResultHandler<ModelNode> resultHandler, ManagementRequestContext<OperationExecutionContext> context, FlushableDataOutput output) throws IOException {
353+
protected void sendRequest(ActiveOperation.ResultHandler<ModelNode> resultHandler, ManagementRequestContext<OperationExecutionContext> context, FlushableDataOutput output) {
354354
//
355355
}
356356

357357
@Override
358-
public void handleRequest(DataInput input, ActiveOperation.ResultHandler<ModelNode> resultHandler, ManagementRequestContext<OperationExecutionContext> context) throws IOException {
358+
public void handleRequest(DataInput input, ActiveOperation.ResultHandler<ModelNode> resultHandler, ManagementRequestContext<OperationExecutionContext> context) {
359359
// Once the remote operation returns, we can set the cancelled status
360360
resultHandler.cancel();
361361
}
@@ -366,7 +366,7 @@ static List<InputStreamEntry> createStreamEntries(final Operation operation) {
366366
if(streams.isEmpty()) {
367367
return Collections.emptyList();
368368
}
369-
final List<InputStreamEntry> entries = new ArrayList<InputStreamEntry>();
369+
final List<InputStreamEntry> entries = new ArrayList<>();
370370
final boolean autoClose = operation.isAutoCloseStreams();
371371
for(final InputStream stream : streams) {
372372
if(stream instanceof InputStreamEntry) {

controller/src/main/java/org/jboss/as/controller/ModelControllerClientFactoryImpl.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public org.jboss.as.controller.client.LocalModelControllerClient createEmbeddedC
7575
* Creates a superuser client that can execute calls that are to be regarded as part of process boot.
7676
* Package protected as this facility should only be made available to kernel code.
7777
*/
78-
final LocalModelControllerClient createBootClient(Executor executor) {
78+
LocalModelControllerClient createBootClient(Executor executor) {
7979
return createSuperUserClient(executor, false, true);
8080
}
8181

@@ -155,7 +155,7 @@ public OperationResponse executeOperation(Operation operation, OperationMessageH
155155
OperationResponse response;
156156
if (forUserCalls) {
157157
final SecurityIdentity securityIdentity = securityIdentitySupplier.get();
158-
response = AccessAuditContext.doAs(securityIdentity, null, new PrivilegedAction<OperationResponse>() {
158+
response = AccessAuditContext.doAs(securityIdentity, null, new PrivilegedAction<>() {
159159

160160
@Override
161161
public OperationResponse run() {
@@ -202,7 +202,7 @@ public void run() {
202202
OperationResponse response;
203203
if (forUserCalls) {
204204
// We need the AccessAuditContext as that will make any inflowed SecurityIdentity available.
205-
response = AccessAuditContext.doAs(securityIdentity, null, new PrivilegedAction<OperationResponse>() {
205+
response = AccessAuditContext.doAs(securityIdentity, null, new PrivilegedAction<>() {
206206

207207
@Override
208208
public OperationResponse run() {
@@ -335,26 +335,18 @@ private interface ResponseConverter<T> {
335335

336336
T fromOperationResponse(OperationResponse or);
337337

338-
ResponseConverter<ModelNode> TO_MODEL_NODE = new ResponseConverter<ModelNode>() {
339-
@Override
340-
public ModelNode fromOperationResponse(OperationResponse or) {
341-
ModelNode result = or.getResponseNode();
342-
try {
343-
or.close();
344-
} catch (IOException e) {
345-
ROOT_LOGGER.debugf(e, "Caught exception closing %s whose associated streams, "
346-
+ "if any, were not wanted", or);
347-
}
348-
return result;
338+
ResponseConverter<ModelNode> TO_MODEL_NODE = or -> {
339+
ModelNode result = or.getResponseNode();
340+
try {
341+
or.close();
342+
} catch (IOException e) {
343+
ROOT_LOGGER.debugf(e, "Caught exception closing %s whose associated streams, "
344+
+ "if any, were not wanted", or);
349345
}
346+
return result;
350347
};
351348

352-
ResponseConverter<OperationResponse> TO_OPERATION_RESPONSE = new ResponseConverter<OperationResponse>() {
353-
@Override
354-
public OperationResponse fromOperationResponse(final OperationResponse or) {
355-
return or;
356-
}
357-
};
349+
ResponseConverter<OperationResponse> TO_OPERATION_RESPONSE = or -> or;
358350
}
359351

360352
private static <T, U, R> R executeInVm(BiFunction<T, U, R> function, T t, U u) {

controller/src/main/java/org/jboss/as/controller/remote/TransactionalProtocolClientImpl.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@
6161
* This implementation uses Management requests to keep operation's transaniolabitility as follows:
6262
* <ul>
6363
* <li>Initiates the transaction with an {@link ExecuteRequest}, which is handled on the remote side via an
64-
* {@link TransactionalProtocolOperationHandler.ExecuteRequestHandler}. This handler executes the operation on the remote
64+
* {@code TransactionalProtocolOperationHandler.ExecuteRequestHandler}. This handler executes the operation on the remote
6565
* controller and returns the prepared response. The operation is suspended on the remote side waiting for the client until a
6666
* commit or rollaback is received.</li>
6767
* <li>Once the prepared response is received on the client side, the operation is committed or rollback on the client side
6868
* which sends the decided TX status to the remote side by using a {@link CompleteTxRequest}. This request is handled on the
69-
* remote side via an {@link TransactionalProtocolOperationHandler.CompleteTxOperationHandler}</li>
69+
* remote side via an {@code TransactionalProtocolOperationHandler.CompleteTxOperationHandler}</li>
7070
* <li>Once the remote side receives the TX status from the client, the prepared operation continues the complete step
7171
* executions and the final result is send back to the client.</li>
7272
* </ul>
@@ -122,7 +122,7 @@ public <T extends Operation> AsyncFuture<OperationResponse> execute(Transactiona
122122
InVmAccess.isInVmCall());
123123
final ActiveOperation<OperationResponse, ExecuteRequestContext> op = channelAssociation.initializeOperation(context, context);
124124
final AtomicBoolean cancelSent = new AtomicBoolean();
125-
final AsyncFuture<OperationResponse> result = new AbstractDelegatingAsyncFuture<OperationResponse>(op.getResult()) {
125+
final AsyncFuture<OperationResponse> result = new AbstractDelegatingAsyncFuture<>(op.getResult()) {
126126
@Override
127127
public synchronized void asyncCancel(boolean interruptionDesired) {
128128
if (!cancelSent.get()) {
@@ -142,8 +142,8 @@ public synchronized void asyncCancel(boolean interruptionDesired) {
142142
}
143143

144144
/**
145-
* Request for the the remote {@link TransactionalProtocolOperationHandler.ExecuteRequestHandler}.
146-
*
145+
* Request for the remote {@code TransactionalProtocolOperationHandler.ExecuteRequestHandler}.
146+
* <p/>
147147
* The required response is either a:
148148
* - {@link org.jboss.as.controller.client.impl.ModelControllerProtocol#PARAM_OPERATION_FAILED}, which will complete the operation right away
149149
* - or {@link org.jboss.as.controller.client.impl.ModelControllerProtocol#PARAM_OPERATION_PREPARED}
@@ -157,12 +157,12 @@ public byte getOperationType() {
157157

158158
@Override
159159
public void sendRequest(final ActiveOperation.ResultHandler<OperationResponse> resultHandler,
160-
final ManagementRequestContext<ExecuteRequestContext> context) throws IOException {
160+
final ManagementRequestContext<ExecuteRequestContext> context) {
161161

162162
ControllerLogger.MGMT_OP_LOGGER.tracef("sending ExecuteRequest for %d", context.getOperationId());
163163
// WFLY-3090 Protect the communication channel from getting closed due to administrative
164164
// cancellation of the management op by using a separate thread to send
165-
context.executeAsync(new ManagementRequestContext.AsyncTask<ExecuteRequestContext>() {
165+
context.executeAsync(new ManagementRequestContext.AsyncTask<>() {
166166
@Override
167167
public void execute(ManagementRequestContext<ExecuteRequestContext> context) throws Exception {
168168
sendRequestInternal(resultHandler, context);
@@ -270,10 +270,10 @@ public byte getOperationType() {
270270

271271
@Override
272272
public void sendRequest(final ActiveOperation.ResultHandler<OperationResponse> resultHandler,
273-
final ManagementRequestContext<ExecuteRequestContext> context) throws IOException {
273+
final ManagementRequestContext<ExecuteRequestContext> context) {
274274

275275
ControllerLogger.MGMT_OP_LOGGER.tracef("sending CompleteTxRequest for %d", context.getOperationId());
276-
context.executeAsync(new ManagementRequestContext.AsyncTask<ExecuteRequestContext>() {
276+
context.executeAsync(new ManagementRequestContext.AsyncTask<>() {
277277
@Override
278278
public void execute(ManagementRequestContext<ExecuteRequestContext> context) throws Exception {
279279
sendRequestInternal(resultHandler, context);
@@ -343,11 +343,11 @@ public void handleRequest(final DataInput input, final ActiveOperation.ResultHan
343343
expectHeader(input, ModelControllerProtocol.PARAM_INPUTSTREAM_INDEX);
344344
final int index = input.readInt();
345345

346-
context.executeAsync(new ManagementRequestContext.AsyncTask<ExecuteRequestContext>() {
346+
context.executeAsync(new ManagementRequestContext.AsyncTask<>() {
347347
@Override
348348
public void execute(final ManagementRequestContext<ExecuteRequestContext> context) throws Exception {
349349
final ExecuteRequestContext exec = context.getAttachment();
350-
final ManagementRequestHeader header = ManagementRequestHeader.class.cast(context.getRequestHeader());
350+
final ManagementRequestHeader header = (ManagementRequestHeader) context.getRequestHeader();
351351
final ManagementResponseHeader response = new ManagementResponseHeader(header.getVersion(), header.getRequestId(), null);
352352
final InputStream is = exec.getAttachments().getInputStreams().get(index);
353353
try {
@@ -500,7 +500,7 @@ OperationAttachments getAttachments() {
500500
}
501501

502502
void prepared(final ModelController.OperationTransaction transaction, final ModelNode result) {
503-
final PreparedOperation<T> preparedOperation = new PreparedOperationImpl<T>(operation, result, future, transaction);
503+
final PreparedOperation<T> preparedOperation = new PreparedOperationImpl<>(operation, result, future, transaction);
504504
listener.operationPrepared(preparedOperation);
505505
}
506506

controller/src/test/java/org/jboss/as/controller/ModelControllerClientTestCase.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void stop() throws Exception {
7171
channels.shutdownRemoting();
7272
}
7373

74-
private ModelControllerClient setupTestClient(final ModelController controller) throws IOException {
74+
private ModelControllerClient setupTestClient(final ModelController controller) {
7575
try {
7676
channels.setupRemoting(new ManagementChannelInitialization() {
7777
@Override
@@ -84,8 +84,8 @@ public ManagementChannelHandler startReceiving(Channel channel) {
8484
}
8585

8686
private ExecutorService getClientRequestExecutor() {
87-
final BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>(512);
88-
final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<ThreadFactory>() {
87+
final BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(512);
88+
final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<>() {
8989
public ThreadFactory run() {
9090
return new JBossThreadFactory(new ThreadGroup("management-handler-thread"), Boolean.FALSE, null, "%G - %t", null, null);
9191
}
@@ -127,7 +127,7 @@ public ModelNode execute(ModelNode operation, OperationMessageHandler handler, O
127127
ModelNode operation = new ModelNode();
128128
operation.get("test").set("123");
129129

130-
final BlockingQueue<String> messages = new LinkedBlockingQueue<String>();
130+
final BlockingQueue<String> messages = new LinkedBlockingQueue<>();
131131

132132
ModelNode result = client.execute(operation,
133133
new OperationMessageHandler() {
@@ -157,16 +157,16 @@ public void testSynchronousAttachmentInputStreams() throws Exception {
157157

158158
final CountDownLatch executeLatch = new CountDownLatch(1);
159159
final AtomicInteger size = new AtomicInteger();
160-
final AtomicReference<byte[]> firstResult = new AtomicReference<byte[]>();
161-
final AtomicReference<byte[]> secondResult = new AtomicReference<byte[]>();
162-
final AtomicReference<byte[]> thirdResult = new AtomicReference<byte[]>();
160+
final AtomicReference<byte[]> firstResult = new AtomicReference<>();
161+
final AtomicReference<byte[]> secondResult = new AtomicReference<>();
162+
final AtomicReference<byte[]> thirdResult = new AtomicReference<>();
163163
MockModelController controller = new MockModelController() {
164164
@Override
165165
public ModelNode execute(ModelNode operation, OperationMessageHandler handler, OperationTransactionControl control, OperationAttachments attachments) {
166166
int streamIndex = 0;
167167
for (InputStream in : attachments.getInputStreams()) {
168168
try {
169-
ArrayList<Integer> readBytes = new ArrayList<Integer>();
169+
ArrayList<Integer> readBytes = new ArrayList<>();
170170
int b = in.read();
171171
while (b != -1) {
172172
readBytes.add(b);
@@ -241,7 +241,7 @@ public ModelNode execute(ModelNode operation, OperationMessageHandler handler, O
241241
operation.get("test").set("123");
242242
operation.get("operation").set("fake");
243243

244-
final BlockingQueue<String> messages = new LinkedBlockingQueue<String>();
244+
final BlockingQueue<String> messages = new LinkedBlockingQueue<>();
245245

246246
Future<ModelNode> resultFuture = client.executeAsync(operation,
247247
new OperationMessageHandler() {
@@ -294,7 +294,7 @@ public ModelNode execute(ModelNode operation, OperationMessageHandler handler, O
294294
operation.get("test").set("123");
295295
operation.get("operation").set("fake");
296296

297-
final BlockingQueue<String> messages = new LinkedBlockingQueue<String>();
297+
final BlockingQueue<String> messages = new LinkedBlockingQueue<>();
298298

299299
Future<ModelNode> resultFuture = client.executeAsync(operation,
300300
new OperationMessageHandler() {
@@ -369,12 +369,11 @@ static class TestEntry extends FilterInputStream implements InputStreamEntry {
369369
}
370370

371371
@Override
372-
public void copyStream(DataOutput output) throws IOException {
373-
return;
372+
public void copyStream(DataOutput output) {
374373
}
375374

376375
@Override
377-
public int initialize() throws IOException {
376+
public int initialize() {
378377
return 0;
379378
}
380379

0 commit comments

Comments
 (0)