Fix minor codestyle issues

This commit is contained in:
Paul Schaub 2017-12-13 23:10:11 +01:00 committed by Florian Schmaus
parent 431e5b3c67
commit 2f2c2f8663
16 changed files with 92 additions and 99 deletions

View File

@ -113,7 +113,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* and reconnection events. * and reconnection events.
*/ */
protected final Set<ConnectionListener> connectionListeners = protected final Set<ConnectionListener> connectionListeners =
new CopyOnWriteArraySet<ConnectionListener>(); new CopyOnWriteArraySet<>();
/** /**
* A collection of StanzaCollectors which collects packets for a specified filter * A collection of StanzaCollectors which collects packets for a specified filter
@ -142,7 +142,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* List of PacketListeners that will be notified when a new stanza(/packet) was sent. * List of PacketListeners that will be notified when a new stanza(/packet) was sent.
*/ */
private final Map<StanzaListener, ListenerWrapper> sendListeners = private final Map<StanzaListener, ListenerWrapper> sendListeners =
new HashMap<StanzaListener, ListenerWrapper>(); new HashMap<>();
/** /**
* List of PacketListeners that will be notified when a new stanza(/packet) is about to be * List of PacketListeners that will be notified when a new stanza(/packet) is about to be
@ -150,11 +150,11 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* actually sent to the server. * actually sent to the server.
*/ */
private final Map<StanzaListener, InterceptorWrapper> interceptors = private final Map<StanzaListener, InterceptorWrapper> interceptors =
new HashMap<StanzaListener, InterceptorWrapper>(); new HashMap<>();
protected final Lock connectionLock = new ReentrantLock(); protected final Lock connectionLock = new ReentrantLock();
protected final Map<String, ExtensionElement> streamFeatures = new HashMap<String, ExtensionElement>(); protected final Map<String, ExtensionElement> streamFeatures = new HashMap<>();
/** /**
* The full JID of the authenticated user, as returned by the resource binding response of the server. * The full JID of the authenticated user, as returned by the resource binding response of the server.
@ -533,7 +533,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
if (!hasFeature(Bind.ELEMENT, Bind.NAMESPACE)) { if (!hasFeature(Bind.ELEMENT, Bind.NAMESPACE)) {
// Server never offered resource binding, which is REQURIED in XMPP client and // Server never offered resource binding, which is REQUIRED in XMPP client and
// server implementations as per RFC6120 7.2 // server implementations as per RFC6120 7.2
throw new ResourceBindingNotOfferedException(); throw new ResourceBindingNotOfferedException();
} }
@ -592,7 +592,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
/** /**
* Get the name of the SASL mechanism that was used to authenticate this connection. This returns the name of * Get the name of the SASL mechanism that was used to authenticate this connection. This returns the name of
* mechanism which was used the last time this conneciton was authenticated, and will return <code>null</code> if * mechanism which was used the last time this connection was authenticated, and will return <code>null</code> if
* this connection was not authenticated before. * this connection was not authenticated before.
* *
* @return the name of the used SASL mechanism. * @return the name of the used SASL mechanism.
@ -621,7 +621,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
hostAddresses.add(hostAddress); hostAddresses.add(hostAddress);
} }
else if (config.host != null) { else if (config.host != null) {
hostAddresses = new ArrayList<HostAddress>(1); hostAddresses = new ArrayList<>(1);
HostAddress hostAddress = DNSUtil.getDNSResolver().lookupHostAddress(config.host, config.port, failedAddresses, config.getDnssecMode()); HostAddress hostAddress = DNSUtil.getDNSResolver().lookupHostAddress(config.host, config.port, failedAddresses, config.getDnssecMode());
if (hostAddress != null) { if (hostAddress != null) {
hostAddresses.add(hostAddress); hostAddresses.add(hostAddress);
@ -862,7 +862,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
debugger.onOutgoingStreamElement(packet); debugger.onOutgoingStreamElement(packet);
} }
final List<StanzaListener> listenersToNotify = new LinkedList<StanzaListener>(); final List<StanzaListener> listenersToNotify = new LinkedList<>();
synchronized (sendListeners) { synchronized (sendListeners) {
for (ListenerWrapper listenerWrapper : sendListeners.values()) { for (ListenerWrapper listenerWrapper : sendListeners.values()) {
if (listenerWrapper.filterMatches(packet)) { if (listenerWrapper.filterMatches(packet)) {
@ -918,7 +918,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @param packet the stanza(/packet) that is going to be sent to the server * @param packet the stanza(/packet) that is going to be sent to the server
*/ */
private void firePacketInterceptors(Stanza packet) { private void firePacketInterceptors(Stanza packet) {
List<StanzaListener> interceptorsToInvoke = new LinkedList<StanzaListener>(); List<StanzaListener> interceptorsToInvoke = new LinkedList<>();
synchronized (interceptors) { synchronized (interceptors) {
for (InterceptorWrapper interceptorWrapper : interceptors.values()) { for (InterceptorWrapper interceptorWrapper : interceptors.values()) {
if (interceptorWrapper.filterMatches(packet)) { if (interceptorWrapper.filterMatches(packet)) {
@ -1029,7 +1029,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
final IQ iq = (IQ) packet; final IQ iq = (IQ) packet;
if (iq.isRequestIQ()) { if (iq.isRequestIQ()) {
final String key = XmppStringUtils.generateKey(iq.getChildElementName(), iq.getChildElementNamespace()); final String key = XmppStringUtils.generateKey(iq.getChildElementName(), iq.getChildElementNamespace());
IQRequestHandler iqRequestHandler = null; IQRequestHandler iqRequestHandler;
final IQ.Type type = iq.getType(); final IQ.Type type = iq.getType();
switch (type) { switch (type) {
case set: case set:
@ -1112,7 +1112,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
// First handle the async recv listeners. Note that this code is very similar to what follows a few lines below, // First handle the async recv listeners. Note that this code is very similar to what follows a few lines below,
// the only difference is that asyncRecvListeners is used here and that the packet listeners are started in // the only difference is that asyncRecvListeners is used here and that the packet listeners are started in
// their own thread. // their own thread.
final Collection<StanzaListener> listenersToNotify = new LinkedList<StanzaListener>(); final Collection<StanzaListener> listenersToNotify = new LinkedList<>();
synchronized (asyncRecvListeners) { synchronized (asyncRecvListeners) {
for (ListenerWrapper listenerWrapper : asyncRecvListeners.values()) { for (ListenerWrapper listenerWrapper : asyncRecvListeners.values()) {
if (listenerWrapper.filterMatches(packet)) { if (listenerWrapper.filterMatches(packet)) {
@ -1342,7 +1342,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
removeCallbacksService.shutdownNow(); removeCallbacksService.shutdownNow();
singleThreadedExecutorService.shutdownNow(); singleThreadedExecutorService.shutdownNow();
} catch (Throwable t) { } catch (Throwable t) {
LOGGER.log(Level.WARNING, "finalize() threw trhowable", t); LOGGER.log(Level.WARNING, "finalize() threw throwable", t);
} }
finally { finally {
super.finalize(); super.finalize();

View File

@ -84,7 +84,7 @@ public abstract class SmackFuture<V, E extends Exception> implements Future<V>,
return this; return this;
} }
private final V getOrThrowExecutionException() throws ExecutionException { private V getOrThrowExecutionException() throws ExecutionException {
assert (result != null || exception != null || cancelled); assert (result != null || exception != null || cancelled);
if (result != null) { if (result != null) {
return result; return result;

View File

@ -78,7 +78,7 @@ public interface XMPPConnection {
* *
* @return the XMPP domain of this XMPP session. * @return the XMPP domain of this XMPP session.
*/ */
public DomainBareJid getXMPPServiceDomain(); DomainBareJid getXMPPServiceDomain();
/** /**
* Returns the host name of the server where the XMPP server is running. This would be the * Returns the host name of the server where the XMPP server is running. This would be the
@ -86,7 +86,7 @@ public interface XMPPConnection {
* *
* @return the host name of the server where the XMPP server is running or null if not yet connected. * @return the host name of the server where the XMPP server is running or null if not yet connected.
*/ */
public String getHost(); String getHost();
/** /**
* Returns the port number of the XMPP server for this connection. The default port * Returns the port number of the XMPP server for this connection. The default port
@ -94,7 +94,7 @@ public interface XMPPConnection {
* *
* @return the port number of the XMPP server or 0 if not yet connected. * @return the port number of the XMPP server or 0 if not yet connected.
*/ */
public int getPort(); int getPort();
/** /**
* Returns the full XMPP address of the user that is logged in to the connection or * Returns the full XMPP address of the user that is logged in to the connection or
@ -103,7 +103,7 @@ public interface XMPPConnection {
* *
* @return the full XMPP address of the user logged in. * @return the full XMPP address of the user logged in.
*/ */
public EntityFullJid getUser(); EntityFullJid getUser();
/** /**
* Returns the stream ID for this connection, which is the value set by the server * Returns the stream ID for this connection, which is the value set by the server
@ -113,35 +113,35 @@ public interface XMPPConnection {
* not connected to the server. * not connected to the server.
* @see <a href="http://xmpp.org/rfcs/rfc6120.html#streams-attr-id">RFC 6120 § 4.7.3. id</a> * @see <a href="http://xmpp.org/rfcs/rfc6120.html#streams-attr-id">RFC 6120 § 4.7.3. id</a>
*/ */
public String getStreamId(); String getStreamId();
/** /**
* Returns true if currently connected to the XMPP server. * Returns true if currently connected to the XMPP server.
* *
* @return true if connected. * @return true if connected.
*/ */
public boolean isConnected(); boolean isConnected();
/** /**
* Returns true if currently authenticated by successfully calling the login method. * Returns true if currently authenticated by successfully calling the login method.
* *
* @return true if authenticated. * @return true if authenticated.
*/ */
public boolean isAuthenticated(); boolean isAuthenticated();
/** /**
* Returns true if currently authenticated anonymously. * Returns true if currently authenticated anonymously.
* *
* @return true if authenticated anonymously. * @return true if authenticated anonymously.
*/ */
public boolean isAnonymous(); boolean isAnonymous();
/** /**
* Returns true if the connection to the server has successfully negotiated encryption. * Returns true if the connection to the server has successfully negotiated encryption.
* *
* @return true if a secure connection to the server. * @return true if a secure connection to the server.
*/ */
public boolean isSecureConnection(); boolean isSecureConnection();
/** /**
* Returns true if network traffic is being compressed. When using stream compression network * Returns true if network traffic is being compressed. When using stream compression network
@ -151,7 +151,7 @@ public interface XMPPConnection {
* *
* @return true if network traffic is being compressed. * @return true if network traffic is being compressed.
*/ */
public boolean isUsingCompression(); boolean isUsingCompression();
/** /**
* Sends the specified stanza to the server. * Sends the specified stanza to the server.
@ -160,7 +160,7 @@ public interface XMPPConnection {
* @throws NotConnectedException if the connection is not connected. * @throws NotConnectedException if the connection is not connected.
* @throws InterruptedException * @throws InterruptedException
* */ * */
public void sendStanza(Stanza stanza) throws NotConnectedException, InterruptedException; void sendStanza(Stanza stanza) throws NotConnectedException, InterruptedException;
/** /**
* Send a Nonza. * Send a Nonza.
@ -174,7 +174,7 @@ public interface XMPPConnection {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public void sendNonza(Nonza nonza) throws NotConnectedException, InterruptedException; void sendNonza(Nonza nonza) throws NotConnectedException, InterruptedException;
/** /**
* Adds a connection listener to this connection that will be notified when * Adds a connection listener to this connection that will be notified when
@ -182,14 +182,14 @@ public interface XMPPConnection {
* *
* @param connectionListener a connection listener. * @param connectionListener a connection listener.
*/ */
public void addConnectionListener(ConnectionListener connectionListener); void addConnectionListener(ConnectionListener connectionListener);
/** /**
* Removes a connection listener from this connection. * Removes a connection listener from this connection.
* *
* @param connectionListener a connection listener. * @param connectionListener a connection listener.
*/ */
public void removeConnectionListener(ConnectionListener connectionListener); void removeConnectionListener(ConnectionListener connectionListener);
/** /**
* Creates a new stanza(/packet) collector collecting packets that are replies to <code>packet</code>. * Creates a new stanza(/packet) collector collecting packets that are replies to <code>packet</code>.
@ -202,7 +202,7 @@ public interface XMPPConnection {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public StanzaCollector createStanzaCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException; StanzaCollector createStanzaCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException;
/** /**
* Creates a new stanza(/packet) collector for this connection. A stanza(/packet) filter determines * Creates a new stanza(/packet) collector for this connection. A stanza(/packet) filter determines
@ -216,7 +216,7 @@ public interface XMPPConnection {
* @throws InterruptedException * @throws InterruptedException
* @throws NotConnectedException * @throws NotConnectedException
*/ */
public StanzaCollector createStanzaCollectorAndSend(StanzaFilter packetFilter, Stanza packet) StanzaCollector createStanzaCollectorAndSend(StanzaFilter packetFilter, Stanza packet)
throws NotConnectedException, InterruptedException; throws NotConnectedException, InterruptedException;
/** /**
@ -235,7 +235,7 @@ public interface XMPPConnection {
* @param packetFilter the stanza(/packet) filter to use. * @param packetFilter the stanza(/packet) filter to use.
* @return a new stanza(/packet) collector. * @return a new stanza(/packet) collector.
*/ */
public StanzaCollector createStanzaCollector(StanzaFilter packetFilter); StanzaCollector createStanzaCollector(StanzaFilter packetFilter);
/** /**
* Create a new stanza(/packet) collector with the given stanza(/packet) collector configuration. * Create a new stanza(/packet) collector with the given stanza(/packet) collector configuration.
@ -248,14 +248,14 @@ public interface XMPPConnection {
* @return a new stanza(/packet) collector. * @return a new stanza(/packet) collector.
* @since 4.1 * @since 4.1
*/ */
public StanzaCollector createStanzaCollector(StanzaCollector.Configuration configuration); StanzaCollector createStanzaCollector(StanzaCollector.Configuration configuration);
/** /**
* Remove a stanza(/packet) collector of this connection. * Remove a stanza(/packet) collector of this connection.
* *
* @param collector a stanza(/packet) collectors which was created for this connection. * @param collector a stanza(/packet) collectors which was created for this connection.
*/ */
public void removeStanzaCollector(StanzaCollector collector); void removeStanzaCollector(StanzaCollector collector);
/** /**
* Registers a <b>synchronous</b> stanza(/packet) listener with this connection. A stanza(/packet) listener will be invoked only when * Registers a <b>synchronous</b> stanza(/packet) listener with this connection. A stanza(/packet) listener will be invoked only when
@ -274,7 +274,7 @@ public interface XMPPConnection {
* @see #addPacketInterceptor(StanzaListener, StanzaFilter) * @see #addPacketInterceptor(StanzaListener, StanzaFilter)
* @since 4.1 * @since 4.1
*/ */
public void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter); void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter);
/** /**
* Removes a stanza(/packet) listener for received packets from this connection. * Removes a stanza(/packet) listener for received packets from this connection.
@ -283,7 +283,7 @@ public interface XMPPConnection {
* @return true if the stanza(/packet) listener was removed * @return true if the stanza(/packet) listener was removed
* @since 4.1 * @since 4.1
*/ */
public boolean removeSyncStanzaListener(StanzaListener packetListener); boolean removeSyncStanzaListener(StanzaListener packetListener);
/** /**
* Registers an <b>asynchronous</b> stanza(/packet) listener with this connection. A stanza(/packet) listener will be invoked only * Registers an <b>asynchronous</b> stanza(/packet) listener with this connection. A stanza(/packet) listener will be invoked only
@ -300,7 +300,7 @@ public interface XMPPConnection {
* @see #addPacketInterceptor(StanzaListener, StanzaFilter) * @see #addPacketInterceptor(StanzaListener, StanzaFilter)
* @since 4.1 * @since 4.1
*/ */
public void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter); void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter);
/** /**
* Removes an <b>asynchronous</b> stanza(/packet) listener for received packets from this connection. * Removes an <b>asynchronous</b> stanza(/packet) listener for received packets from this connection.
@ -309,7 +309,7 @@ public interface XMPPConnection {
* @return true if the stanza(/packet) listener was removed * @return true if the stanza(/packet) listener was removed
* @since 4.1 * @since 4.1
*/ */
public boolean removeAsyncStanzaListener(StanzaListener packetListener); boolean removeAsyncStanzaListener(StanzaListener packetListener);
/** /**
* Registers a stanza(/packet) listener with this connection. The listener will be * Registers a stanza(/packet) listener with this connection. The listener will be
@ -322,14 +322,14 @@ public interface XMPPConnection {
* @param packetListener the stanza(/packet) listener to notify of sent packets. * @param packetListener the stanza(/packet) listener to notify of sent packets.
* @param packetFilter the stanza(/packet) filter to use. * @param packetFilter the stanza(/packet) filter to use.
*/ */
public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter); void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter);
/** /**
* Removes a stanza(/packet) listener for sending packets from this connection. * Removes a stanza(/packet) listener for sending packets from this connection.
* *
* @param packetListener the stanza(/packet) listener to remove. * @param packetListener the stanza(/packet) listener to remove.
*/ */
public void removePacketSendingListener(StanzaListener packetListener); void removePacketSendingListener(StanzaListener packetListener);
/** /**
* Registers a stanza(/packet) interceptor with this connection. The interceptor will be * Registers a stanza(/packet) interceptor with this connection. The interceptor will be
@ -343,14 +343,14 @@ public interface XMPPConnection {
* @param packetInterceptor the stanza(/packet) interceptor to notify of packets about to be sent. * @param packetInterceptor the stanza(/packet) interceptor to notify of packets about to be sent.
* @param packetFilter the stanza(/packet) filter to use. * @param packetFilter the stanza(/packet) filter to use.
*/ */
public void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter); void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter);
/** /**
* Removes a stanza(/packet) interceptor. * Removes a stanza(/packet) interceptor.
* *
* @param packetInterceptor the stanza(/packet) interceptor to remove. * @param packetInterceptor the stanza(/packet) interceptor to remove.
*/ */
public void removePacketInterceptor(StanzaListener packetInterceptor); void removePacketInterceptor(StanzaListener packetInterceptor);
/** /**
* Returns the current value of the reply timeout in milliseconds for request for this * Returns the current value of the reply timeout in milliseconds for request for this
@ -358,7 +358,7 @@ public interface XMPPConnection {
* *
* @return the reply timeout in milliseconds * @return the reply timeout in milliseconds
*/ */
public long getReplyTimeout(); long getReplyTimeout();
/** /**
* Set the stanza(/packet) reply timeout in milliseconds. In most cases, Smack will throw a * Set the stanza(/packet) reply timeout in milliseconds. In most cases, Smack will throw a
@ -366,7 +366,7 @@ public interface XMPPConnection {
* *
* @param timeout for a reply in milliseconds * @param timeout for a reply in milliseconds
*/ */
public void setReplyTimeout(long timeout); void setReplyTimeout(long timeout);
/** /**
* Get the connection counter of this XMPPConnection instance. Those can be used as ID to * Get the connection counter of this XMPPConnection instance. Those can be used as ID to
@ -375,9 +375,9 @@ public interface XMPPConnection {
* *
* @return the connection counter of this XMPPConnection * @return the connection counter of this XMPPConnection
*/ */
public int getConnectionCounter(); int getConnectionCounter();
public static enum FromMode { enum FromMode {
/** /**
* Leave the 'from' attribute unchanged. This is the behavior of Smack < 4.0 * Leave the 'from' attribute unchanged. This is the behavior of Smack < 4.0
*/ */
@ -400,14 +400,14 @@ public interface XMPPConnection {
* *
* @param fromMode * @param fromMode
*/ */
public void setFromMode(FromMode fromMode); void setFromMode(FromMode fromMode);
/** /**
* Get the currently active FromMode. * Get the currently active FromMode.
* *
* @return the currently active {@link FromMode} * @return the currently active {@link FromMode}
*/ */
public FromMode getFromMode(); FromMode getFromMode();
/** /**
* Get the feature stanza(/packet) extensions for a given stream feature of the * Get the feature stanza(/packet) extensions for a given stream feature of the
@ -417,7 +417,7 @@ public interface XMPPConnection {
* @param namespace * @param namespace
* @return a stanza(/packet) extensions of the feature or <code>null</code> * @return a stanza(/packet) extensions of the feature or <code>null</code>
*/ */
public <F extends ExtensionElement> F getFeature(String element, String namespace); <F extends ExtensionElement> F getFeature(String element, String namespace);
/** /**
* Return true if the server supports the given stream feature. * Return true if the server supports the given stream feature.
@ -426,7 +426,7 @@ public interface XMPPConnection {
* @param namespace * @param namespace
* @return true if the server supports the stream feature. * @return true if the server supports the stream feature.
*/ */
public boolean hasFeature(String element, String namespace); boolean hasFeature(String element, String namespace);
/** /**
* Send an IQ request asynchronously. The connection's default reply timeout will be used. * Send an IQ request asynchronously. The connection's default reply timeout will be used.
@ -434,7 +434,7 @@ public interface XMPPConnection {
* @param request the IQ request to send. * @param request the IQ request to send.
* @return a SmackFuture for the response. * @return a SmackFuture for the response.
*/ */
public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request); SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request);
/** /**
* Send an IQ request asynchronously. * Send an IQ request asynchronously.
@ -443,7 +443,7 @@ public interface XMPPConnection {
* @param timeout the reply timeout in milliseconds. * @param timeout the reply timeout in milliseconds.
* @return a SmackFuture for the response. * @return a SmackFuture for the response.
*/ */
public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request, long timeout); SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request, long timeout);
/** /**
* Send a stanza asynchronously, waiting for exactly one response stanza using the given reply filter. The * Send a stanza asynchronously, waiting for exactly one response stanza using the given reply filter. The
@ -453,7 +453,7 @@ public interface XMPPConnection {
* @param replyFilter the filter used for the response stanza. * @param replyFilter the filter used for the response stanza.
* @return a SmackFuture for the response. * @return a SmackFuture for the response.
*/ */
public <S extends Stanza> SmackFuture<S, Exception> sendAsync(S stanza, StanzaFilter replyFilter); <S extends Stanza> SmackFuture<S, Exception> sendAsync(S stanza, StanzaFilter replyFilter);
/** /**
* Send a stanza asynchronously, waiting for exactly one response stanza using the given reply filter. * Send a stanza asynchronously, waiting for exactly one response stanza using the given reply filter.
@ -463,7 +463,7 @@ public interface XMPPConnection {
* @param timeout the reply timeout in milliseconds. * @param timeout the reply timeout in milliseconds.
* @return a SmackFuture for the response. * @return a SmackFuture for the response.
*/ */
public <S extends Stanza> SmackFuture<S, Exception> sendAsync(S stanza, StanzaFilter replyFilter, long timeout); <S extends Stanza> SmackFuture<S, Exception> sendAsync(S stanza, StanzaFilter replyFilter, long timeout);
/** /**
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>. * Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
@ -482,7 +482,7 @@ public interface XMPPConnection {
*/ */
@Deprecated @Deprecated
// TODO: Remove in Smack 4.4. // TODO: Remove in Smack 4.4.
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
StanzaListener callback) throws NotConnectedException, InterruptedException; StanzaListener callback) throws NotConnectedException, InterruptedException;
/** /**
@ -503,7 +503,7 @@ public interface XMPPConnection {
*/ */
@Deprecated @Deprecated
// TODO: Remove in Smack 4.4. // TODO: Remove in Smack 4.4.
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback, void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback,
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException; @SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
/** /**
@ -525,7 +525,7 @@ public interface XMPPConnection {
*/ */
@Deprecated @Deprecated
// TODO: Remove in Smack 4.4. // TODO: Remove in Smack 4.4.
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
final StanzaListener callback, @SuppressWarnings("deprecation") final ExceptionCallback exceptionCallback, final StanzaListener callback, @SuppressWarnings("deprecation") final ExceptionCallback exceptionCallback,
long timeout) throws NotConnectedException, InterruptedException; long timeout) throws NotConnectedException, InterruptedException;
@ -542,7 +542,7 @@ public interface XMPPConnection {
*/ */
@Deprecated @Deprecated
// TODO: Remove in Smack 4.4. // TODO: Remove in Smack 4.4.
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException, InterruptedException; void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException, InterruptedException;
/** /**
* Send a IQ stanza and invoke <code>callback</code> if there is a result of * Send a IQ stanza and invoke <code>callback</code> if there is a result of
@ -561,7 +561,7 @@ public interface XMPPConnection {
*/ */
@Deprecated @Deprecated
// TODO: Remove in Smack 4.4. // TODO: Remove in Smack 4.4.
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback, void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException; @SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
/** /**
@ -582,7 +582,7 @@ public interface XMPPConnection {
*/ */
@Deprecated @Deprecated
// TODO: Remove in Smack 4.4. // TODO: Remove in Smack 4.4.
public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback, void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
@SuppressWarnings("deprecation") final ExceptionCallback exceptionCallback, long timeout) @SuppressWarnings("deprecation") final ExceptionCallback exceptionCallback, long timeout)
throws NotConnectedException, InterruptedException; throws NotConnectedException, InterruptedException;
@ -593,7 +593,7 @@ public interface XMPPConnection {
* @param callback the callback invoked once the stanza(/packet) filter matches a stanza. * @param callback the callback invoked once the stanza(/packet) filter matches a stanza.
* @param packetFilter the filter to match stanzas or null to match all. * @param packetFilter the filter to match stanzas or null to match all.
*/ */
public void addOneTimeSyncCallback(StanzaListener callback, StanzaFilter packetFilter); void addOneTimeSyncCallback(StanzaListener callback, StanzaFilter packetFilter);
/** /**
* Register an IQ request handler with this connection. * Register an IQ request handler with this connection.
@ -603,7 +603,7 @@ public interface XMPPConnection {
* @param iqRequestHandler the IQ request handler to register. * @param iqRequestHandler the IQ request handler to register.
* @return the previously registered IQ request handler or null. * @return the previously registered IQ request handler or null.
*/ */
public IQRequestHandler registerIQRequestHandler(IQRequestHandler iqRequestHandler); IQRequestHandler registerIQRequestHandler(IQRequestHandler iqRequestHandler);
/** /**
* Convenience method for {@link #unregisterIQRequestHandler(String, String, org.jivesoftware.smack.packet.IQ.Type)}. * Convenience method for {@link #unregisterIQRequestHandler(String, String, org.jivesoftware.smack.packet.IQ.Type)}.
@ -611,7 +611,7 @@ public interface XMPPConnection {
* @param iqRequestHandler * @param iqRequestHandler
* @return the previously registered IQ request handler or null. * @return the previously registered IQ request handler or null.
*/ */
public IQRequestHandler unregisterIQRequestHandler(IQRequestHandler iqRequestHandler); IQRequestHandler unregisterIQRequestHandler(IQRequestHandler iqRequestHandler);
/** /**
* Unregister an IQ request handler with this connection. * Unregister an IQ request handler with this connection.
@ -621,13 +621,13 @@ public interface XMPPConnection {
* @param type the IQ type the IQ request handler is responsible for. * @param type the IQ type the IQ request handler is responsible for.
* @return the previously registered IQ request handler or null. * @return the previously registered IQ request handler or null.
*/ */
public IQRequestHandler unregisterIQRequestHandler(String element, String namespace, IQ.Type type); IQRequestHandler unregisterIQRequestHandler(String element, String namespace, IQ.Type type);
/** /**
* Returns the timestamp in milliseconds when the last stanza was received. * Returns the timestamp in milliseconds when the last stanza was received.
* *
* @return the timestamp in milliseconds * @return the timestamp in milliseconds
*/ */
public long getLastStanzaReceived(); long getLastStanzaReceived();
} }

View File

@ -18,6 +18,6 @@ package org.jivesoftware.smack.util;
public interface ExceptionCallback<E> { public interface ExceptionCallback<E> {
public void processException(E exception); void processException(E exception);
} }

View File

@ -49,8 +49,6 @@ public class HashElementTest extends SmackTestSuite {
assertEquals("f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=", parsed.getHashB64()); assertEquals("f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=", parsed.getHashB64());
assertArrayEquals(HashManager.sha_256(message), parsed.getHash()); assertArrayEquals(HashManager.sha_256(message), parsed.getHash());
assertFalse(parsed.equals(expected));
assertFalse(parsed.equals(null));
assertEquals(element, parsed); assertEquals(element, parsed);
assertTrue(element.equals(parsed)); assertTrue(element.equals(parsed));

View File

@ -46,14 +46,14 @@ public interface BytestreamManager {
* *
* @param listener the listener to register * @param listener the listener to register
*/ */
public void addIncomingBytestreamListener(BytestreamListener listener); void addIncomingBytestreamListener(BytestreamListener listener);
/** /**
* Removes the given listener from the list of listeners for all incoming bytestream requests. * Removes the given listener from the list of listeners for all incoming bytestream requests.
* *
* @param listener the listener to remove * @param listener the listener to remove
*/ */
public void removeIncomingBytestreamListener(BytestreamListener listener); void removeIncomingBytestreamListener(BytestreamListener listener);
/** /**
* Adds {@link BytestreamListener} that is called for every incoming bytestream request unless * Adds {@link BytestreamListener} that is called for every incoming bytestream request unless
@ -68,14 +68,14 @@ public interface BytestreamManager {
* @param listener the listener to register * @param listener the listener to register
* @param initiatorJID the JID of the user that wants to establish a bytestream * @param initiatorJID the JID of the user that wants to establish a bytestream
*/ */
public void addIncomingBytestreamListener(BytestreamListener listener, Jid initiatorJID); void addIncomingBytestreamListener(BytestreamListener listener, Jid initiatorJID);
/** /**
* Removes the listener for the given user. * Removes the listener for the given user.
* *
* @param initiatorJID the JID of the user the listener should be removed * @param initiatorJID the JID of the user the listener should be removed
*/ */
public void removeIncomingBytestreamListener(Jid initiatorJID); void removeIncomingBytestreamListener(Jid initiatorJID);
/** /**
* Establishes a bytestream with the given user and returns the session to send/receive data * Establishes a bytestream with the given user and returns the session to send/receive data
@ -97,7 +97,7 @@ public interface BytestreamManager {
* @throws InterruptedException if the thread was interrupted while waiting in a blocking * @throws InterruptedException if the thread was interrupted while waiting in a blocking
* operation * operation
*/ */
public BytestreamSession establishSession(Jid targetJID) throws XMPPException, IOException, BytestreamSession establishSession(Jid targetJID) throws XMPPException, IOException,
InterruptedException, SmackException; InterruptedException, SmackException;
/** /**
@ -115,7 +115,7 @@ public interface BytestreamManager {
* @throws InterruptedException if the thread was interrupted while waiting in a blocking * @throws InterruptedException if the thread was interrupted while waiting in a blocking
* operation * operation
*/ */
public BytestreamSession establishSession(Jid targetJID, String sessionID) BytestreamSession establishSession(Jid targetJID, String sessionID)
throws XMPPException, IOException, InterruptedException, SmackException; throws XMPPException, IOException, InterruptedException, SmackException;
} }

View File

@ -77,7 +77,7 @@ public final class AdHocCommandManager extends Manager {
* Map an XMPPConnection with it AdHocCommandManager. This map have a key-value * Map an XMPPConnection with it AdHocCommandManager. This map have a key-value
* pair for every active connection. * pair for every active connection.
*/ */
private static Map<XMPPConnection, AdHocCommandManager> instances = new WeakHashMap<>(); private static final Map<XMPPConnection, AdHocCommandManager> instances = new WeakHashMap<>();
/** /**
* Register the listener for all the connection creations. When a new * Register the listener for all the connection creations. When a new
@ -114,7 +114,7 @@ public final class AdHocCommandManager extends Manager {
* Value=command. Command node matches the node attribute sent by command * Value=command. Command node matches the node attribute sent by command
* requesters. * requesters.
*/ */
private final Map<String, AdHocCommandInfo> commands = new ConcurrentHashMap<String, AdHocCommandInfo>(); private final Map<String, AdHocCommandInfo> commands = new ConcurrentHashMap<>();
/** /**
* Map a command session ID with the instance LocalCommand. The LocalCommand * Map a command session ID with the instance LocalCommand. The LocalCommand
@ -122,7 +122,7 @@ public final class AdHocCommandManager extends Manager {
* the command execution. Note: Key=session ID, Value=LocalCommand. Session * the command execution. Note: Key=session ID, Value=LocalCommand. Session
* ID matches the sessionid attribute sent by command responders. * ID matches the sessionid attribute sent by command responders.
*/ */
private final Map<String, LocalCommand> executingCommands = new ConcurrentHashMap<String, LocalCommand>(); private final Map<String, LocalCommand> executingCommands = new ConcurrentHashMap<>();
private final ServiceDiscoveryManager serviceDiscoveryManager; private final ServiceDiscoveryManager serviceDiscoveryManager;
@ -155,7 +155,7 @@ public final class AdHocCommandManager extends Manager {
@Override @Override
public List<DiscoverItems.Item> getNodeItems() { public List<DiscoverItems.Item> getNodeItems() {
List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>(); List<DiscoverItems.Item> answer = new ArrayList<>();
Collection<AdHocCommandInfo> commandsList = getRegisteredCommands(); Collection<AdHocCommandInfo> commandsList = getRegisteredCommands();
for (AdHocCommandInfo info : commandsList) { for (AdHocCommandInfo info : commandsList) {
@ -181,7 +181,7 @@ public final class AdHocCommandManager extends Manager {
return processAdHocCommand(requestData); return processAdHocCommand(requestData);
} }
catch (InterruptedException | NoResponseException | NotConnectedException e) { catch (InterruptedException | NoResponseException | NotConnectedException e) {
LOGGER.log(Level.INFO, "processAdHocCommand threw exceptino", e); LOGGER.log(Level.INFO, "processAdHocCommand threw exception", e);
return null; return null;
} }
} }
@ -215,7 +215,7 @@ public final class AdHocCommandManager extends Manager {
* Registers a new command with this command manager, which is related to a * Registers a new command with this command manager, which is related to a
* connection. The <tt>node</tt> is an unique identifier of that * connection. The <tt>node</tt> is an unique identifier of that
* command for the connection related to this command manager. The <tt>name</tt> * command for the connection related to this command manager. The <tt>name</tt>
* is the human readeale name of the command. The <tt>factory</tt> generates * is the human readable name of the command. The <tt>factory</tt> generates
* new instances of the command. * new instances of the command.
* *
* @param node the unique identifier of the command. * @param node the unique identifier of the command.
@ -232,7 +232,7 @@ public final class AdHocCommandManager extends Manager {
new AbstractNodeInformationProvider() { new AbstractNodeInformationProvider() {
@Override @Override
public List<String> getNodeFeatures() { public List<String> getNodeFeatures() {
List<String> answer = new ArrayList<String>(); List<String> answer = new ArrayList<>();
answer.add(NAMESPACE); answer.add(NAMESPACE);
// TODO: check if this service is provided by the // TODO: check if this service is provided by the
// TODO: current connection. // TODO: current connection.
@ -241,7 +241,7 @@ public final class AdHocCommandManager extends Manager {
} }
@Override @Override
public List<DiscoverInfo.Identity> getNodeIdentities() { public List<DiscoverInfo.Identity> getNodeIdentities() {
List<DiscoverInfo.Identity> answer = new ArrayList<DiscoverInfo.Identity>(); List<DiscoverInfo.Identity> answer = new ArrayList<>();
DiscoverInfo.Identity identity = new DiscoverInfo.Identity( DiscoverInfo.Identity identity = new DiscoverInfo.Identity(
"automation", name, "command-node"); "automation", name, "command-node");
answer.add(identity); answer.add(identity);
@ -353,7 +353,7 @@ public final class AdHocCommandManager extends Manager {
try { try {
// Create a new instance of the command with the // Create a new instance of the command with the
// corresponding sessioid // corresponding sessionid
LocalCommand command; LocalCommand command;
try { try {
command = newInstanceOfCmd(commandNode, sessionId); command = newInstanceOfCmd(commandNode, sessionId);
@ -425,7 +425,7 @@ public final class AdHocCommandManager extends Manager {
// the requester know why his execution request is // the requester know why his execution request is
// not accepted. If the session is removed just // not accepted. If the session is removed just
// after the time out, then whe the user request to // after the time out, then whe the user request to
// continue the execution he will recieved an // continue the execution he will received an
// invalid session error and not a time out error. // invalid session error and not a time out error.
if (System.currentTimeMillis() - creationStamp > SESSION_TIMEOUT * 1000 * 2) { if (System.currentTimeMillis() - creationStamp > SESSION_TIMEOUT * 1000 * 2) {
// Remove the expired session // Remove the expired session

View File

@ -41,6 +41,6 @@ public interface LocalCommandFactory {
* @throws InvocationTargetException * @throws InvocationTargetException
* @throws IllegalArgumentException * @throws IllegalArgumentException
*/ */
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException; LocalCommand getInstance() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException;
} }

View File

@ -182,7 +182,7 @@ public class IncomingFileTransfer extends FileTransfer {
final StreamNegotiator streamNegotiator = negotiator final StreamNegotiator streamNegotiator = negotiator
.selectStreamNegotiator(receiveRequest); .selectStreamNegotiator(receiveRequest);
setStatus(Status.negotiating_stream); setStatus(Status.negotiating_stream);
FutureTask<InputStream> streamNegotiatorTask = new FutureTask<InputStream>( FutureTask<InputStream> streamNegotiatorTask = new FutureTask<>(
new Callable<InputStream>() { new Callable<InputStream>() {
@Override @Override

View File

@ -94,7 +94,7 @@ public final class Jingle extends IQ {
/** /**
* Get the responder. The responder is the full JID of the entity that has replied to the initiation (which may be * Get the responder. The responder is the full JID of the entity that has replied to the initiation (which may be
* different to the "to" addresss in the IQ). * different to the "to" address in the IQ).
* *
* @return the responder * @return the responder
*/ */

View File

@ -44,7 +44,7 @@ public enum JingleAction {
transport_replace, transport_replace,
; ;
private static final Map<String, JingleAction> map = new HashMap<String, JingleAction>( private static final Map<String, JingleAction> map = new HashMap<>(
JingleAction.values().length); JingleAction.values().length);
static { static {
for (JingleAction jingleAction : JingleAction.values()) { for (JingleAction jingleAction : JingleAction.values()) {
@ -54,7 +54,7 @@ public enum JingleAction {
private final String asString; private final String asString;
private JingleAction() { JingleAction() {
asString = this.name().replace('_', '-'); asString = this.name().replace('_', '-');
} }

View File

@ -16,9 +16,6 @@
*/ */
package org.jivesoftware.smackx.jingle.transports; package org.jivesoftware.smackx.jingle.transports;
/**
* Created by vanitas on 25.06.17.
*/
public abstract class JingleTransportInitiationException extends Exception { public abstract class JingleTransportInitiationException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -22,9 +22,6 @@ import org.jivesoftware.smackx.jingle.element.Jingle;
import org.jivesoftware.smackx.jingle.element.JingleContent; import org.jivesoftware.smackx.jingle.element.JingleContent;
import org.jivesoftware.smackx.jingle.element.JingleContentTransport; import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
/**
* Created by vanitas on 20.06.17.
*/
public abstract class JingleTransportSession<T extends JingleContentTransport> { public abstract class JingleTransportSession<T extends JingleContentTransport> {
protected final JingleSession jingleSession; protected final JingleSession jingleSession;
protected T ourProposal, theirProposal; protected T ourProposal, theirProposal;

View File

@ -98,5 +98,6 @@ public class JingleUtilTest extends SmackTestSuite {
"</content>" + "</content>" +
"</jingle>" + "</jingle>" +
"</iq>"; "</iq>";
// TODO: Finish test
} }
} }

View File

@ -55,8 +55,8 @@ public class JingleProviderTest {
JingleContentDescription jingleContentDescription = jingle.getSoleContentOrThrow().getDescription(); JingleContentDescription jingleContentDescription = jingle.getSoleContentOrThrow().getDescription();
String parsedUnknownJingleContentDescrptionNamespace = jingleContentDescription.getNamespace(); String parsedUnknownJingleContentDescriptionNamespace = jingleContentDescription.getNamespace();
assertEquals(unknownJingleContentDescriptionNamespace, parsedUnknownJingleContentDescrptionNamespace); assertEquals(unknownJingleContentDescriptionNamespace, parsedUnknownJingleContentDescriptionNamespace);
} }
@Test @Test

View File

@ -104,8 +104,8 @@ public class FormTest extends AbstractSmackIntegrationTest {
chat.sendMessage(msg); chat.sendMessage(msg);
// Get the message with the form to fill out // Get the message with the form to fill out
Message msg2 = (Message) collector2.nextResult(); Message msg2 = collector2.nextResult();
assertNotNull("Messge not found", msg2); assertNotNull("Message not found", msg2);
// Retrieve the form to fill out // Retrieve the form to fill out
Form formToRespond = Form.getFormFrom(msg2); Form formToRespond = Form.getFormFrom(msg2);
assertNotNull(formToRespond); assertNotNull(formToRespond);
@ -140,8 +140,8 @@ public class FormTest extends AbstractSmackIntegrationTest {
conTwo.sendStanza(msg2); conTwo.sendStanza(msg2);
// Get the message with the completed form // Get the message with the completed form
Message msg3 = (Message) collector.nextResult(); Message msg3 = collector.nextResult();
assertNotNull("Messge not found", msg3); assertNotNull("Message not found", msg3);
// Retrieve the completed form // Retrieve the completed form
completedForm = Form.getFormFrom(msg3); completedForm = Form.getFormFrom(msg3);
assertNotNull(completedForm); assertNotNull(completedForm);