1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-12 05:51:08 +01:00

Fix minor codestyle issues

This commit is contained in:
Paul Schaub 2017-12-13 23:10:11 +01:00 committed by Florian Schmaus
parent 200f90ffdc
commit cb18056613
422 changed files with 1404 additions and 1444 deletions

View file

@ -45,6 +45,6 @@ public interface BytestreamListener {
*
* @param request the incoming bytestream request
*/
public void incomingBytestreamRequest(BytestreamRequest request);
void incomingBytestreamRequest(BytestreamRequest request);
}

View file

@ -41,14 +41,14 @@ public interface BytestreamRequest {
*
* @return the sender of the bytestream open request
*/
public Jid getFrom();
Jid getFrom();
/**
* Returns the session ID of the bytestream open request.
*
* @return the session ID of the bytestream open request
*/
public String getSessionID();
String getSessionID();
/**
* Accepts the bytestream open request and returns the session to send/receive data.
@ -60,13 +60,13 @@ public interface BytestreamRequest {
* @throws NoResponseException
* @throws SmackException
*/
public BytestreamSession accept() throws InterruptedException, NoResponseException, XMPPErrorException, SmackException;
BytestreamSession accept() throws InterruptedException, XMPPErrorException, SmackException;
/**
* Rejects the bytestream request by sending a reject error to the initiator.
* @throws NotConnectedException
* @throws InterruptedException
*/
public void reject() throws NotConnectedException, InterruptedException;
void reject() throws NotConnectedException, InterruptedException;
}

View file

@ -39,7 +39,7 @@ public interface BytestreamSession {
* @return the InputStream associated with this session to send data
* @throws IOException if an error occurs while retrieving the input stream
*/
public InputStream getInputStream() throws IOException;
InputStream getInputStream() throws IOException;
/**
* Returns the OutputStream associated with this session to receive data.
@ -47,7 +47,7 @@ public interface BytestreamSession {
* @return the OutputStream associated with this session to receive data
* @throws IOException if an error occurs while retrieving the output stream
*/
public OutputStream getOutputStream() throws IOException;
OutputStream getOutputStream() throws IOException;
/**
* Closes the bytestream session.
@ -57,7 +57,7 @@ public interface BytestreamSession {
*
* @throws IOException if an error occurs while closing the session
*/
public void close() throws IOException;
void close() throws IOException;
/**
* Returns the timeout for read operations of the input stream associated with this session. 0
@ -66,7 +66,7 @@ public interface BytestreamSession {
* @return the timeout for read operations
* @throws IOException if there is an error in the underlying protocol
*/
public int getReadTimeout() throws IOException;
int getReadTimeout() throws IOException;
/**
* Sets the specified timeout, in milliseconds. With this option set to a non-zero timeout, a
@ -79,6 +79,6 @@ public interface BytestreamSession {
* @param timeout the specified timeout, in milliseconds
* @throws IOException if there is an error in the underlying protocol
*/
public void setReadTimeout(int timeout) throws IOException;
void setReadTimeout(int timeout) throws IOException;
}

View file

@ -181,7 +181,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* list containing session IDs of In-Band Bytestream open packets that should be ignored by the
* InitiationListener
*/
private List<String> ignoredBytestreamRequests = Collections.synchronizedList(new LinkedList<String>());
private final List<String> ignoredBytestreamRequests = Collections.synchronizedList(new LinkedList<String>());
/**
* Returns the InBandBytestreamManager to handle In-Band Bytestreams for a given

View file

@ -532,7 +532,7 @@ public class InBandBytestreamSession implements BytestreamSession {
@Override
public void processStanza(Stanza packet) {
// get data packet extension
DataPacketExtension data = (DataPacketExtension) packet.getExtension(
DataPacketExtension data = packet.getExtension(
DataPacketExtension.ELEMENT,
DataPacketExtension.NAMESPACE);

View file

@ -40,8 +40,7 @@ public class DataPacketProvider {
public Data parse(XmlPullParser parser, int initialDepth)
throws Exception {
DataPacketExtension data = packetExtensionProvider.parse(parser);
Data iq = new Data(data);
return iq;
return new Data(data);
}
}

View file

@ -40,7 +40,7 @@ public class OpenIQProvider extends IQProvider<Open> {
int blockSize = Integer.parseInt(parser.getAttributeValue("", "block-size"));
String stanzaValue = parser.getAttributeValue("", "stanza");
StanzaType stanza = null;
StanzaType stanza;
if (stanzaValue == null) {
stanza = StanzaType.IQ;
}

View file

@ -152,7 +152,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
* list containing session IDs of SOCKS5 Bytestream initialization packets that should be
* ignored by the InitiationListener
*/
private List<String> ignoredBytestreamRequests = Collections.synchronizedList(new LinkedList<String>());
private final List<String> ignoredBytestreamRequests = Collections.synchronizedList(new LinkedList<String>());
/**
* Returns the Socks5BytestreamManager to handle SOCKS5 Bytestreams for a given
@ -411,13 +411,12 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
* @return the Socket to send/receive data to/from the user
* @throws IOException if the bytestream could not be established
* @throws InterruptedException if the current thread was interrupted while waiting
* @throws NoResponseException
* @throws SmackException if the target does not support SOCKS5.
* @throws XMPPException
*/
@Override
public Socks5BytestreamSession establishSession(Jid targetJID, String sessionID)
throws IOException, InterruptedException, NoResponseException, SmackException, XMPPException {
throws IOException, InterruptedException, SmackException, XMPPException {
XMPPConnection connection = connection();
XMPPErrorException discoveryException = null;
// check if target supports SOCKS5 Bytestream
@ -589,7 +588,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
*/
private List<StreamHost> determineStreamHostInfos(List<Jid> proxies) {
XMPPConnection connection = connection();
List<StreamHost> streamHosts = new ArrayList<StreamHost>();
List<StreamHost> streamHosts = new ArrayList<>();
// add local proxy on first position if exists
List<StreamHost> localProxies = getLocalStreamHost();
@ -601,7 +600,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
for (Jid proxy : proxies) {
Bytestream streamHostRequest = createStreamHostRequest(proxy);
try {
Bytestream response = (Bytestream) connection.createStanzaCollectorAndSend(
Bytestream response = connection.createStanzaCollectorAndSend(
streamHostRequest).nextResultOrThrow();
streamHosts.addAll(response.getStreamHosts());
}
@ -650,7 +649,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
}
final int port = socks5Server.getPort();
List<StreamHost> streamHosts = new ArrayList<StreamHost>();
List<StreamHost> streamHosts = new ArrayList<>();
outerloop: for (String address : addresses) {
// Prevent loopback addresses from appearing as streamhost
final String[] loopbackAddresses = { "127.0.0.1", "0:0:0:0:0:0:0:1", "::1" };

View file

@ -34,9 +34,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
/**
@ -74,16 +72,15 @@ class Socks5Client {
* @param timeout timeout to connect to SOCKS5 proxy in milliseconds
* @return socket the initialized socket
* @throws IOException if initializing the socket failed due to a network error
* @throws XMPPErrorException if establishing connection to SOCKS5 proxy failed
* @throws TimeoutException if connecting to SOCKS5 proxy timed out
* @throws InterruptedException if the current thread was interrupted while waiting
* @throws SmackException if the connection to the SOC
* @throws SmackException if the connection to the SOCKS5 proxy failed
* @throws XMPPException
*/
public Socket getSocket(int timeout) throws IOException, XMPPErrorException, InterruptedException,
public Socket getSocket(int timeout) throws IOException, InterruptedException,
TimeoutException, SmackException, XMPPException {
// wrap connecting in future for timeout
FutureTask<Socket> futureTask = new FutureTask<Socket>(new Callable<Socket>() {
FutureTask<Socket> futureTask = new FutureTask<>(new Callable<Socket>() {
@Override
public Socket call() throws IOException, SmackException {
@ -173,7 +170,7 @@ class Socks5Client {
// check if server responded with correct version and no-authentication method
if (response[0] != (byte) 0x05 || response[1] != (byte) 0x00) {
throw new SmackException("Remote SOCKS5 server responsed with unexpected version: " + response[0] + ' ' + response[1] + ". Should be 0x05 0x00.");
throw new SmackException("Remote SOCKS5 server responded with unexpected version: " + response[0] + ' ' + response[1] + ". Should be 0x05 0x00.");
}
// request SOCKS5 connection with given address/digest
@ -188,7 +185,7 @@ class Socks5Client {
connectionRequest[1] = (byte) 0x00; // set expected return status to 0
if (!Arrays.equals(connectionRequest, connectionResponse)) {
throw new SmackException(
"Connection request does not equal connection reponse. Response: "
"Connection request does not equal connection response. Response: "
+ Arrays.toString(connectionResponse) + ". Request: "
+ Arrays.toString(connectionRequest));
}

View file

@ -74,7 +74,7 @@ class Socks5ClientForInitiator extends Socks5Client {
@Override
public Socket getSocket(int timeout) throws IOException, InterruptedException,
TimeoutException, XMPPException, SmackException {
Socket socket = null;
Socket socket;
// check if stream host is the local SOCKS5 proxy
if (this.streamHost.getJID().equals(this.connection.get().getUser())) {

View file

@ -93,12 +93,12 @@ public final class Socks5Proxy {
private ServerSocket serverSocket;
/* assigns a connection to a digest */
private final Map<String, Socket> connectionMap = new ConcurrentHashMap<String, Socket>();
private final Map<String, Socket> connectionMap = new ConcurrentHashMap<>();
/* list of digests connections should be stored */
private final List<String> allowedConnections = Collections.synchronizedList(new LinkedList<String>());
private final Set<String> localAddresses = new LinkedHashSet<String>(4);
private final Set<String> localAddresses = new LinkedHashSet<>(4);
/**
* Private constructor.
@ -112,7 +112,7 @@ public final class Socks5Proxy {
} catch (SocketException e) {
throw new IllegalStateException(e);
}
Set<String> localHostAddresses = new HashSet<String>();
Set<String> localHostAddresses = new HashSet<>();
for (NetworkInterface networkInterface : Collections.list(networkInterfaces)) {
// We can't use NetworkInterface.getInterfaceAddresses here, which
// would return a List instead the deprecated Enumeration, because
@ -293,7 +293,7 @@ public final class Socks5Proxy {
*/
public List<String> getLocalAddresses() {
synchronized (localAddresses) {
return new LinkedList<String>(localAddresses);
return new LinkedList<>(localAddresses);
}
}

View file

@ -46,7 +46,7 @@ public class Bytestream extends IQ {
private Mode mode = Mode.tcp;
private final List<StreamHost> streamHosts = new ArrayList<StreamHost>();
private final List<StreamHost> streamHosts = new ArrayList<>();
private StreamHostUsed usedHost;