Skip to content

Commit

Permalink
Fixed some minor comment warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyor Goldstein committed Dec 7, 2023
1 parent 52227d9 commit f25d800
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public Throwable getException() {

public static IoWriteFuture fulfilled(Object id, Object value) {
AbstractIoWriteFuture result = new AbstractIoWriteFuture(id, null) {
// Nothing extra
};
result.setValue(Objects.requireNonNull(value));
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@
import java.nio.channels.Channel;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.LinkOption;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -362,9 +371,10 @@ public void testBreakOutOfChroot6() throws IOException {
}

/**
* Tests to make sure that the attempted break out of the chroot does not work with the specified filename
* Tests to make sure that the attempted break out of the {@code chroot} does not work with the specified filename
*
* @param fileName the filename to attempt to break out of the chroot with
* @param fileName the filename to attempt to break out of the {@code chroot} with
* @param expected the expected attempt result
* @throws IOException on test failure
*/
private void testBreakOutOfChroot(String fileName, String expected) throws IOException {
Expand Down Expand Up @@ -535,7 +545,7 @@ public Path createTestSandbox(Path tempDir) throws IOException {

public Path createFile(Path source) throws InvalidPathException, IOException {
try (FileChannel fc = fileSystem.provider().newFileChannel(source,
new TreeSet<OpenOption>(Arrays.asList(StandardOpenOption.CREATE, StandardOpenOption.WRITE)))) {
new TreeSet<>(Arrays.asList(StandardOpenOption.CREATE, StandardOpenOption.WRITE)))) {
byte[] randomBytes = new byte[1000];
new Random().nextBytes(randomBytes);
fc.write(ByteBuffer.wrap(randomBytes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ default void signalAuthenticationExhausted(ClientSession session, String service
/**
* A {@link KeyPair} is is present, but is not attempted because no signature factory for it could be found.
*
* @param session The {@link ClientSession}
* @param service The requesting service name
* @param identity The {@link KeyPair} identity being skipped - <B>Note:</B> for agent based authentications the
* private key may be {@code null}
* @param session The {@link ClientSession}
* @param service The requesting service name
* @param identity The {@link KeyPair} identity being skipped - <B>Note:</B> for agent based authentications the
* private key may be {@code null}
* @throws Exception If failed to handle the callback - <B>Note:</B> may cause session close
*/
default void signalIdentitySkipped(ClientSession session, String service, KeyPair identity) throws Exception {
// ignored
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public interface AuthFuture extends SshFuture<AuthFuture>, VerifiableFuture<Auth
/**
* Tells whether {@link #cancel()} was called on this {@link AuthFuture}.
* <p>
* This is different from {@link #isCanceled()}. Cancelling an on-going authentication may not be possible;
* This is different from {@link #isCanceled()}. Canceling an on-going authentication may not be possible;
* {@link #cancel()} is only a <em>request</em> to cancel the authentication. That request may not be honored and
* the {@link org.apache.sshd.common.future.CancelFuture CancelFuture} may actually be
* {@link org.apache.sshd.common.future.CancelFuture#isCanceled() isCanceled()} {@code == false}.
* {@link AuthFuture}.{@link isCanceled()} is then {@code false}, too.
* {@link AuthFuture}.{@link #isCanceled()} is then {@code false}, too.
* </p>
*
* @return {@code true} if {@link #cancel()} was called, {@code false} otherwise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ public PacketValidator getPacketValidator() {
/**
* Sets a {@link PacketValidator}.
*
* @param the validator to set, if {@code null} the {@link #DEFAULT_PACKET_VALIDATOR} is set
* @param validator the validator to set, if {@code null} the {@link #DEFAULT_PACKET_VALIDATOR} is set
*/
public void setPacketValidator(PacketValidator validator) {
if (validator == null) {
Expand Down Expand Up @@ -991,6 +991,7 @@ protected IoWriteFuture sendEof() throws IOException {
}

AbstractIoWriteFuture eofWritten = new AbstractIoWriteFuture(getChannelId(), futureLock) {
// Nothin extra
};
if (!eofFuture.compareAndSet(null, eofWritten)) {
if (log.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ default Buffer request(String request, Buffer buffer, Duration timeout) throws I
* appropriate
* @param request the request name
* @param replyHandler {@link ReplyHandler} for handling the reply; may be {@code null}
* @return Created {@link GlobalRequestFuture}
* @throws IOException if an error occurred while encoding or sending the packet
*/
GlobalRequestFuture request(Buffer buffer, String request, ReplyHandler replyHandler)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ public abstract class AbstractSession extends SessionHelper {
*
* @see <a href="https://tools.ietf.org/html/rfc4254#section-4">RFC 4254: Global Requests</a>
* @see <a href="https://tools.ietf.org/html/rfc4253#section-11.4">RFC 4254: Reserved Messages</a>
* @see {@link #request(Buffer, String, org.apache.sshd.common.future.GlobalRequestFuture.ReplyHandler)}
* @see {@link #requestSuccess(Buffer)}
* @see {@link #requestFailure(Buffer)}
* @see {@link #doInvokeUnimplementedMessageHandler(int, Buffer)}
* @see {@link #preClose()}
* @see #request(Buffer, String, org.apache.sshd.common.future.GlobalRequestFuture.ReplyHandler)
* @see #requestSuccess(Buffer)
* @see #requestFailure(Buffer)
* @see #doInvokeUnimplementedMessageHandler(int, Buffer)
* @see #preClose()
*/
private final Deque<GlobalRequestFuture> pendingGlobalRequests = new ConcurrentLinkedDeque<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
/**
* Manages SSH message sending during a key exchange. RFC 4253 specifies that during a key exchange, no high-level
* messages are to be sent, but a receiver must be able to deal with messages "in flight" until the peer's
* {@link SshConstants#SSH_MSG_KEX_INIT} message is received.
* {@link SshConstants#SSH_MSG_KEXINIT} message is received.
* <p>
* Apache MINA sshd queues up high-level messages that threads try to send while a key exchange is ongoing, and sends
* them once the key exchange is done. Sending queued messages may make the peer re-trigger a new key exchange, in which
Expand Down Expand Up @@ -165,11 +165,11 @@ public <V> V updateState(Supplier<V> update) {
}

/**
* Initializes the state for a new key exchange. {@link #allPacketsFlushed()} will be {@code false}, and a new
* future to be fulfilled when all queued packets will be flushed once the key exchange is done is set. The
* currently set future from an earlier key exchange is returned. The returned future may or may not be fulfilled;
* if it isn't, there are still left-over pending packets to write from the previous key exchange, which will be
* written once the new key exchange flushes pending packets.
* Initializes the state for a new key exchange. {@code allPacketsFlushed} will be {@code false}, and a new future
* to be fulfilled when all queued packets will be flushed once the key exchange is done is set. The currently set
* future from an earlier key exchange is returned. The returned future may or may not be fulfilled; if it isn't,
* there are still left-over pending packets to write from the previous key exchange, which will be written once the
* new key exchange flushes pending packets.
*
* @return the previous {@link DefaultKeyExchangeFuture} indicating whether all pending packets were flushed.
*/
Expand Down Expand Up @@ -204,7 +204,7 @@ public void shutdown() {
shutDown.set(true);
SimpleImmutableEntry<Integer, DefaultKeyExchangeFuture> items = updateState(() -> {
kexFlushed.set(true);
return new SimpleImmutableEntry<Integer, DefaultKeyExchangeFuture>(
return new SimpleImmutableEntry<>(
Integer.valueOf(pendingPackets.size()),
kexFlushedFuture.get());
});
Expand Down Expand Up @@ -419,7 +419,7 @@ protected PendingWriteFuture enqueuePendingPacket(int cmd, Buffer buffer) {
* exchange, flushing is stopped and is to be resumed by another call to this method when the new key exchange is
* done.
*
* @param flushDone the future obtained from {@link #getFlushedFuture()}; will be fulfilled once all pending packets
* @param flushDone the future obtained from {@code getFlushedFuture}; will be fulfilled once all pending packets
* have been written
*/
protected void flushQueue(DefaultKeyExchangeFuture flushDone) {
Expand Down Expand Up @@ -455,6 +455,7 @@ protected void flushQueue(DefaultKeyExchangeFuture flushDone) {
if (!session.isOpen()) {
log.info("flushQueue({}): Session closed while flushing pending packets at end of KEX", session);
AbstractIoWriteFuture aborted = new AbstractIoWriteFuture(session, null) {
// Nothing extra
};
aborted.setValue(new SshException("Session closed while flushing pending packets at end of KEX"));
drainQueueTo(pendingFutures, aborted);
Expand Down Expand Up @@ -505,6 +506,7 @@ protected void flushQueue(DefaultKeyExchangeFuture flushDone) {
log.error("flushQueue({}): Exception while flushing packet at end of KEX for {}", session,
pending.getId(), e);
AbstractIoWriteFuture aborted = new AbstractIoWriteFuture(pending.getId(), null) {
// Nothing extra
};
aborted.setValue(e);
pendingFutures.add(new SimpleImmutableEntry<>(pending, aborted));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ChannelSessionTest() {
super();
}

/**
/*
* Testing a command closing output stream when it completes
*/
@Test // see SSHD-1257
Expand Down

0 comments on commit f25d800

Please sign in to comment.