Skip to content

Upgrade to Checkstyle 8.28 #9790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion alts/src/main/java/io/grpc/alts/AltsContextUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/7864")
public final class AltsContextUtil {

private AltsContextUtil(){}
private AltsContextUtil() {}

/**
* Creates a {@link AltsContext} from ALTS context information in the {@link ServerCall}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void getBytesToSendToPeer(ByteBuffer bytes) throws GeneralSecurityExcepti
}

/**
* Returns true if and only if the handshake is still in progress
* Returns true if and only if the handshake is still in progress.
*
* @return true, if the handshake is still in progress, false otherwise.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ boolean processBytesFromPeer(ByteBuf data) throws GeneralSecurityException {
}

/**
* Returns true if and only if the handshake is still in progress
* Returns true if and only if the handshake is still in progress.
*
* @return true, if the handshake is still in progress, false otherwise.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public interface TsiHandshaker {
boolean processBytesFromPeer(ByteBuffer bytes) throws GeneralSecurityException;

/**
* Returns true if and only if the handshake is still in progress
* Returns true if and only if the handshake is still in progress.
*
* @return true, if the handshake is still in progress, false otherwise.
*/
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/io/grpc/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ public String toString() {
abstract T parseBytes(byte[] serialized);

/**
* @return whether this key will be serialized to bytes lazily.
* Returns whether this key will be serialized to bytes lazily.
*/
boolean serializesToStreams() {
return false;
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/io/grpc/NameResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ void onAddresses(
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1770")
public abstract static class Listener2 implements Listener {
/**
* Handles updates on resolved addresses and attributes.
*
* @deprecated This will be removed in 1.22.0
*/
@Override
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/io/grpc/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ private static boolean isEscapingChar(byte b) {
}

/**
* Percent encode bytes to make them ASCII.
*
* @param valueBytes the UTF-8 bytes
* @param ri The reader index, pointed at the first byte that needs escaping.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import io.grpc.testing.protobuf.SimpleRequest;
import io.grpc.testing.protobuf.SimpleResponse;
import io.grpc.testing.protobuf.SimpleServiceGrpc;

import java.io.File;
import org.junit.After;
import org.junit.Test;
Expand Down
15 changes: 5 additions & 10 deletions benchmarks/src/jmh/java/io/grpc/benchmarks/TransportBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,20 @@ public void setUp() throws Exception {
ServerBuilder<?> serverBuilder;
ManagedChannelBuilder<?> channelBuilder;
switch (transport) {
case INPROCESS:
{
case INPROCESS: {
String name = "bench" + Math.random();
serverBuilder = InProcessServerBuilder.forName(name);
channelBuilder = InProcessChannelBuilder.forName(name);
break;
}
case NETTY:
{
case NETTY: {
InetSocketAddress address = new InetSocketAddress("localhost", pickUnusedPort());
serverBuilder = NettyServerBuilder.forAddress(address, serverCreds);
channelBuilder = NettyChannelBuilder.forAddress(address)
.negotiationType(NegotiationType.PLAINTEXT);
break;
}
case NETTY_LOCAL:
{
case NETTY_LOCAL: {
String name = "bench" + Math.random();
LocalAddress address = new LocalAddress(name);
EventLoopGroup group = new DefaultEventLoopGroup();
Expand All @@ -118,8 +115,7 @@ public void setUp() throws Exception {
groupToShutdown = group;
break;
}
case NETTY_EPOLL:
{
case NETTY_EPOLL: {
InetSocketAddress address = new InetSocketAddress("localhost", pickUnusedPort());

// Reflection used since they are only available on linux.
Expand All @@ -143,8 +139,7 @@ public void setUp() throws Exception {
groupToShutdown = group;
break;
}
case OKHTTP:
{
case OKHTTP: {
int port = pickUnusedPort();
InetSocketAddress address = new InetSocketAddress("localhost", port);
serverBuilder = NettyServerBuilder.forAddress(address, serverCreds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.junit.runners.JUnit4;

/**
* Basic tests for {@link io.grpc.benchmarks.driver.LoadWorker}
* Basic tests for {@link io.grpc.benchmarks.driver.LoadWorker}.
*/
@RunWith(JUnit4.class)
public class LoadWorkerTest {
Expand Down
18 changes: 6 additions & 12 deletions buildscripts/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<property name="eachLine" value="true"/>
</module>

<module name="LineLength">
<property name="max" value="100"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

<module name="TreeWalker">
<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
Expand All @@ -45,10 +50,6 @@
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<module name="LineLength">
<property name="max" value="100"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="AvoidStarImport"/>
<!-- TODO(ejona): Upstream? -->
<module name="UnusedImports"/>
Expand All @@ -59,12 +60,8 @@
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
</module>
<module name="NeedBraces"/>
<module name="LeftCurly">
<property name="maxLineLength" value="100"/>
</module>
<module name="RightCurly"/>
<module name="LeftCurly"/>
<module name="RightCurly">
<property name="option" value="alone"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="WhitespaceAround">
Expand Down Expand Up @@ -204,13 +201,10 @@
<module name="JavadocMethod">
<property name="scope" value="public"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="minLineCount" value="2"/>
<!-- TOOD(ejona): Too restrictive for tests
<property name="allowedAnnotations" value="Override, Test"/-->
<property name="allowedAnnotations" value="Override, Test, Before, After, BeforeClass, AfterClass, Setup, TearDown"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
</module>
<module name="MethodName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public static ClientInterceptor getClientInterceptor() {
}

/**
* @param addMessageEvents add message events to Spans
* Returns the client interceptor that facilitates Census-based stats reporting.
*
* @param addMessageEvents add message events to Spans
* @return a {@link ClientInterceptor} with default tracing implementation.
*/
public static ClientInterceptor getClientInterceptor(
Expand Down
4 changes: 3 additions & 1 deletion context/src/main/java/io/grpc/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@ public String toString() {
*/
public abstract static class Storage {
/**
* Unused.
*
* @deprecated This is an old API that is no longer used.
*/
@Deprecated
Expand Down Expand Up @@ -1029,7 +1031,7 @@ public Context doAttach(Context toAttach) {
}

/**
* Implements {@link io.grpc.Context#detach}
* Implements {@link io.grpc.Context#detach}.
*
* @param toDetach the context to be detached. Should be, or be equivalent to, the current
* context of the current scope
Expand Down
9 changes: 5 additions & 4 deletions context/src/main/java/io/grpc/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public final class Deadline implements Comparable<Deadline> {
*
* <p>This is <strong>EXPERIMENTAL</strong> API and may subject to change. If you'd like it to be
* stabilized or have any feedback, please
* <href a="https://github.com/grpc/grpc-java/issues/6030">let us know</a>.
* <a href="https://github.com/grpc/grpc-java/issues/6030">let us know</a>.
*
* @since 1.24.0
*/
Expand Down Expand Up @@ -81,7 +81,7 @@ public static Deadline after(long duration, TimeUnit units) {
*
* <p>This is <strong>EXPERIMENTAL</strong> API and may subject to change. If you'd like it to be
* stabilized or have any feedback, please
* <href a="https://github.com/grpc/grpc-java/issues/6030">let us know</a>.
* <a href="https://github.com/grpc/grpc-java/issues/6030">let us know</a>.
*
* @param duration A non-negative duration.
* @param units The time unit for the duration.
Expand Down Expand Up @@ -113,7 +113,8 @@ private Deadline(Ticker ticker, long baseInstant, long offset,
}

/**
* Has this deadline expired
* Returns whether this has deadline expired.
*
* @return {@code true} if it has, otherwise {@code false}.
*/
public boolean isExpired() {
Expand Down Expand Up @@ -266,7 +267,7 @@ public boolean equals(final Object o) {
*
* <p>This is <strong>EXPERIMENTAL</strong> API and may subject to change. If you'd like it to be
* stabilized or have any feedback, please
* <href a="https://github.com/grpc/grpc-java/issues/6030">let us know</a>.
* <a href="https://github.com/grpc/grpc-java/issues/6030">let us know</a>.
*
* <p>In general implementations should be thread-safe, unless it's implemented and used in a
* localized environment (like unit tests) where you are sure the usages are synchronized.
Expand Down
13 changes: 8 additions & 5 deletions core/src/main/java/io/grpc/inprocess/InProcessSocketAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ public final class InProcessSocketAddress extends SocketAddress {
private final String name;

/**
* @param name - The name of the inprocess channel or server.
* Construct an address for a server identified by name.
*
* @param name The name of the inprocess server.
* @since 1.0.0
*/
public InProcessSocketAddress(String name) {
this.name = checkNotNull(name, "name");
}

/**
* Gets the name of the inprocess channel or server.
* Gets the name of the inprocess server.
*
* @since 1.0.0
*/
Expand All @@ -46,22 +48,23 @@ public String getName() {
}

/**
* Returns {@link #getName}.
*
* @since 1.14.0
*/
@Override
public String toString() {
return name;
}

/**
* @since 1.15.0
*/
@Override
public int hashCode() {
return name.hashCode();
}

/**
* Returns {@code true} if the object is of the same type and server names match.
*
* @since 1.15.0
*/
@Override
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/io/grpc/internal/DnsNameResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ final int getPort() {
}

/**
* Parse TXT service config records as JSON.
*
* @throws IOException if one of the txt records contains improperly formatted JSON.
*/
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/io/grpc/internal/GrpcUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ public static String getHost(InetSocketAddress addr) {
/**
* Marshals a nanoseconds representation of the timeout to and from a string representation,
* consisting of an ASCII decimal representation of a number with at most 8 digits, followed by a
* unit:
* unit. Available units:
* n = nanoseconds
* u = microseconds
* m = milliseconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.base.Throwables;

import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2287,7 +2287,7 @@ public <T> T invokeAny(Collection<? extends Callable<T>> tasks)

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
throws InterruptedException, ExecutionException, TimeoutException {
return delegate.invokeAny(tasks, timeout, unit);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ static String makeTargetStringForDirectAddress(SocketAddress address) {
public ManagedChannelImplBuilder(SocketAddress directServerAddress, String authority,
ClientTransportFactoryBuilder clientTransportFactoryBuilder,
@Nullable ChannelBuilderDefaultPortProvider channelBuilderDefaultPortProvider) {
this(directServerAddress, authority, null, null, clientTransportFactoryBuilder,
channelBuilderDefaultPortProvider);
this(directServerAddress, authority, null, null, clientTransportFactoryBuilder,
channelBuilderDefaultPortProvider);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/io/grpc/internal/ProxyDetectorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ public ProxySelector get() {
};

/**
* Experimental environment variable name for enabling proxy support.
*
* @deprecated Use the standard Java proxy configuration instead with flags such as:
* -Dhttps.proxyHost=HOST -Dhttps.proxyPort=PORT
*/
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/io/grpc/internal/ServiceConfigState.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ final class ServiceConfigState {
private boolean updated;

/**
* Construct new instance.
*
* @param defaultServiceConfig The initial service config, or {@code null} if absent.
* @param lookUpServiceConfig {@code true} if service config updates might occur.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import io.grpc.ConnectivityState;
import io.grpc.EquivalentAddressGroup;
import io.grpc.ExperimentalApi;
import io.grpc.LoadBalancer;
import io.grpc.LoadBalancer.CreateSubchannelArgs;
import io.grpc.LoadBalancer.Subchannel;
import io.grpc.LoadBalancer.SubchannelPicker;
import io.grpc.LoadBalancer;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.NameResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ServerServiceDefinition addService(BindableService bindableService) {
}

/**
* Removes a registered service
* Removes a registered service.
*
* @return true if the service was found to be removed.
*/
Expand Down
2 changes: 2 additions & 0 deletions core/src/test/java/io/grpc/internal/MessageDeframerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ public void sizeEnforcingInputStream_markReset() throws IOException {
}

/**
* Verify stats were published through the tracer.
*
* @param transportStats the transport level stats counters
* @param clock the fakeClock to verify timestamp
* @param sizes in the format {wire0, uncompressed0, wire1, uncompressed1, ...}
Expand Down
2 changes: 2 additions & 0 deletions core/src/test/java/io/grpc/internal/MessageFramerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ private static void writeKnownLength(MessageFramer framer, byte[] bytes) {
}

/**
* Verify stats were published through the tracer.
*
* @param sizes in the format {wire0, uncompressed0, wire1, uncompressed1, ...}
*/
private void checkStats(long... sizes) {
Expand Down
Loading