Skip to content

Commit

Permalink
Format repository with Spotless (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Jun 18, 2024
1 parent 42201e3 commit 3ea58fc
Show file tree
Hide file tree
Showing 257 changed files with 6,905 additions and 5,151 deletions.
42 changes: 21 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,6 @@ THE SOFTWARE.
<version>2.16.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
Expand All @@ -170,6 +155,21 @@ THE SOFTWARE.
<artifactId>test-annotations</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down Expand Up @@ -333,7 +333,8 @@ THE SOFTWARE.
<descriptor>src/assembly/agent-load-test.xml</descriptor>
</descriptors>
<attach>false</attach>
<tarLongFileMode>posix</tarLongFileMode> <!-- https://maven.apache.org/plugins/maven-assembly-plugin/faq.html#tarFileModes -->
<tarLongFileMode>posix</tarLongFileMode>
<!-- https://maven.apache.org/plugins/maven-assembly-plugin/faq.html#tarFileModes -->
</configuration>
<executions>
<execution>
Expand All @@ -347,7 +348,8 @@ THE SOFTWARE.
</execution>
</executions>
</plugin>
<plugin> <!-- TODO probably superseded by Incrementals? -->
<plugin>
<!-- TODO probably superseded by Incrementals? -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
Expand Down Expand Up @@ -396,11 +398,9 @@ THE SOFTWARE.
<rerunFailingTestsCount>4</rerunFailingTestsCount>
<properties>
<!-- https://junit.org/junit5/docs/snapshot/user-guide/#writing-tests-declarative-timeouts -->
<configurationParameters>
junit.jupiter.execution.timeout.default=15s
<configurationParameters>junit.jupiter.execution.timeout.default=15s
junit.jupiter.execution.timeout.mode=disabled_on_debug
junit.jupiter.execution.timeout.thread.mode.default=SEPARATE_THREAD
</configurationParameters>
junit.jupiter.execution.timeout.thread.mode.default=SEPARATE_THREAD</configurationParameters>
</properties>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ public abstract class AbstractByteBufferCommandTransport extends CommandTranspor
* Our channel.
*/
private Channel channel;

@Deprecated
private final ByteBuffer writeChunkHeader;
/**
* The transport frame size.
*/
private int transportFrameSize = 8192;

@Deprecated
private ByteBuffer writeChunkBody;
/**
Expand Down Expand Up @@ -354,5 +356,4 @@ public final void write(Command cmd, boolean last) throws IOException {
public void terminate(IOException e) {
receiver.terminate(e);
}

}
34 changes: 21 additions & 13 deletions src/main/java/hudson/remoting/AsyncFutureImpl.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, CloudBees, Inc.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -33,7 +33,7 @@
* {@link Future} implementation whose computation is carried out elsewhere.
*
* Call the {@link #set(Object)} method or {@link #set(Throwable)} method to set the value to the future.
*
*
* @author Kohsuke Kawaguchi
*/
public class AsyncFutureImpl<V> implements Future<V> {
Expand All @@ -50,9 +50,11 @@ public class AsyncFutureImpl<V> implements Future<V> {
private boolean cancelled;

public AsyncFutureImpl() {}

public AsyncFutureImpl(V value) {
set(value);
}

public AsyncFutureImpl(Throwable value) {
set(value);
}
Expand All @@ -74,18 +76,22 @@ public synchronized boolean isDone() {

@Override
public synchronized V get() throws InterruptedException, ExecutionException {
while(!completed)
while (!completed) {
wait();
if(problem!=null)
}
if (problem != null) {
throw new ExecutionException(problem);
if(cancelled)
}
if (cancelled) {
throw new CancellationException();
}
return value;
}

@Override
@CheckForNull
public synchronized V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
public synchronized V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
// The accuracy of wait(long) operation is milliseconds anyway, but ok.
long endWaitTime = System.nanoTime() + unit.toNanos(timeout);
while (!completed) {
Expand All @@ -94,15 +100,17 @@ public synchronized V get(long timeout, TimeUnit unit) throws InterruptedExcepti
break;
}

wait(timeToWait / 1000000, (int)(timeToWait % 1000000));
wait(timeToWait / 1000000, (int) (timeToWait % 1000000));
}

if(!completed)
if (!completed) {
throw new TimeoutException();
if(cancelled)
}
if (cancelled) {
throw new CancellationException();
}

//TODO: we may be calling a complex get() implementation in the override, which may hang the code
// TODO: we may be calling a complex get() implementation in the override, which may hang the code

Check warning on line 113 in src/main/java/hudson/remoting/AsyncFutureImpl.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: we may be calling a complex get() implementation in the override, which may hang the code
// The only missing behavior is "problem!=null" branch, but probably we cannot just replace the code without
// an override issue risk.
return get();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/hudson/remoting/Asynchronous.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,4 @@
@Documented
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Asynchronous {
}
public @interface Asynchronous {}
7 changes: 4 additions & 3 deletions src/main/java/hudson/remoting/AtmostOneThreadExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ public AtmostOneThreadExecutor() {
public void shutdown() {
synchronized (q) {
shutdown = true;
if (isAlive())
if (isAlive()) {
worker.interrupt();
}
}
}

/**
* Do we have a worker thread and is it running?
*/
private boolean isAlive() {
return worker!=null && worker.isAlive();
return worker != null && worker.isAlive();
}

@NonNull
Expand Down Expand Up @@ -111,7 +112,7 @@ public void run() {
while (true) {
Runnable task;
synchronized (q) {
if (q.isEmpty()) {// no more work
if (q.isEmpty()) { // no more work
worker = null;
return;
}
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/hudson/remoting/Base64.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @deprecated Use {@link java.util.Base64} instead
*/
@Deprecated
public final class Base64 {
public final class Base64 {

/**
* Encodes hex octets into Base64
Expand All @@ -48,8 +48,9 @@ public final class Base64 {
@Nullable
public static String encode(byte[] binaryData) {

if (binaryData == null)
if (binaryData == null) {
return null;
}

return java.util.Base64.getEncoder().encodeToString(binaryData);
}
Expand All @@ -61,12 +62,14 @@ public static String encode(byte[] binaryData) {
* @return Array containing decoded data. {@code null} if the data cannot be decoded.
*/
@CheckForNull
@SuppressFBWarnings(value = "PZLA_PREFER_ZERO_LENGTH_ARRAYS",
@SuppressFBWarnings(
value = "PZLA_PREFER_ZERO_LENGTH_ARRAYS",
justification = "Null arrays are the part of the library API")
public static byte[] decode(String encoded) {

if (encoded == null)
if (encoded == null) {
return null;
}

return java.util.Base64.getDecoder().decode(encoded);
}
Expand Down
Loading

0 comments on commit 3ea58fc

Please sign in to comment.