Browse Source

Bump "Error Prone" to 2.0.15

and fix a few things :)
tags/4.2.0
Florian Schmaus 3 years ago
parent
commit
4c646436a5
100 changed files with 563 additions and 60 deletions
  1. +1
    -1
      build.gradle
  2. +1
    -0
      smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java
  3. +20
    -4
      smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java
  4. +1
    -0
      smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
  5. +2
    -0
      smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java
  6. +3
    -2
      smack-core/src/main/java/org/jivesoftware/smack/SmackInitialization.java
  7. +16
    -0
      smack-core/src/main/java/org/jivesoftware/smack/debugger/AbstractDebugger.java
  8. +2
    -0
      smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractFromToMatchesFilter.java
  9. +1
    -0
      smack-core/src/main/java/org/jivesoftware/smack/filter/AndFilter.java
  10. +1
    -0
      smack-core/src/main/java/org/jivesoftware/smack/filter/NotFilter.java
  11. +1
    -0
      smack-core/src/main/java/org/jivesoftware/smack/filter/PacketExtensionFilter.java
  12. +2
    -0
      smack-core/src/main/java/org/jivesoftware/smack/filter/PacketIDFilter.java
  13. +1
    -0
      smack-core/src/main/java/org/jivesoftware/smack/filter/PacketTypeFilter.java
  14. +1
    -0
      smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaExtensionFilter.java
  15. +2
    -0
      smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaIdFilter.java
  16. +1
    -0
      smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaTypeFilter.java
  17. +2
    -0
      smack-core/src/main/java/org/jivesoftware/smack/packet/DefaultExtensionElement.java
  18. +4
    -0
      smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java
  19. +1
    -1
      smack-core/src/main/java/org/jivesoftware/smack/provider/IntrospectionProvider.java
  20. +7
    -3
      smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java
  21. +4
    -1
      smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks4ProxySocketConnection.java
  22. +8
    -4
      smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks5ProxySocketConnection.java
  23. +3
    -2
      smack-core/src/main/java/org/jivesoftware/smack/sasl/SASLMechanism.java
  24. +1
    -0
      smack-core/src/main/java/org/jivesoftware/smack/sasl/core/SASLAnonymous.java
  25. +20
    -4
      smack-core/src/main/java/org/jivesoftware/smack/sasl/core/ScramMechanism.java
  26. +4
    -0
      smack-core/src/main/java/org/jivesoftware/smack/util/ArrayBlockingQueueWithShutdown.java
  27. +4
    -1
      smack-core/src/main/java/org/jivesoftware/smack/util/FileUtils.java
  28. +9
    -0
      smack-core/src/main/java/org/jivesoftware/smack/util/ObservableReader.java
  29. +7
    -0
      smack-core/src/main/java/org/jivesoftware/smack/util/ObservableWriter.java
  30. +33
    -4
      smack-core/src/main/java/org/jivesoftware/smack/util/stringencoder/Base32.java
  31. +1
    -0
      smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java
  32. +3
    -3
      smack-core/src/test/java/org/jivesoftware/smack/StanzaCollectorTest.java
  33. +3
    -2
      smack-core/src/test/java/org/jivesoftware/smack/sasl/DigestMd5SaslTest.java
  34. +1
    -0
      smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java
  35. +7
    -5
      smack-core/src/test/java/org/jivesoftware/smack/util/StringUtilsTest.java
  36. +5
    -0
      smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JLoggingConnectionListener.java
  37. +1
    -0
      smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JLoggingPacketListener.java
  38. +2
    -0
      smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JRawXmlListener.java
  39. +50
    -5
      smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
  40. +7
    -2
      smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java
  41. +19
    -1
      smack-debug/src/main/java/org/jivesoftware/smackx/debugger/LiteDebugger.java
  42. +2
    -0
      smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java
  43. +1
    -0
      smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/packet/AbstractHttpOverXmpp.java
  44. +17
    -2
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/control/element/IoTSetRequest.java
  45. +1
    -1
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/control/element/SetData.java
  46. +1
    -0
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/IoTDataManager.java
  47. +1
    -0
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java
  48. +1
    -0
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/element/NodeInfo.java
  49. +1
    -0
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java
  50. +66
    -3
      smack-extensions/src/main/java/org/jivesoftware/smack/chat2/ChatManager.java
  51. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/amp/AMPManager.java
  52. +3
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/attention/packet/AttentionExtension.java
  53. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/BookmarkedConference.java
  54. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/BookmarkedURL.java
  55. +3
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java
  56. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamListener.java
  57. +9
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java
  58. +4
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamRequest.java
  59. +24
    -1
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java
  60. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InitiationListener.java
  61. +2
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/packet/DataPacketExtension.java
  62. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/InitiationListener.java
  63. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamListener.java
  64. +9
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java
  65. +4
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamRequest.java
  66. +5
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamSession.java
  67. +10
    -1
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5Client.java
  68. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5ClientForInitiator.java
  69. +3
    -1
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5Proxy.java
  70. +3
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/packet/Bytestream.java
  71. +16
    -1
      smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java
  72. +2
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/caps/packet/CapsExtension.java
  73. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java
  74. +5
    -1
      smack-extensions/src/main/java/org/jivesoftware/smackx/chatstates/ChatStateManager.java
  75. +2
    -1
      smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommand.java
  76. +12
    -1
      smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java
  77. +3
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/commands/packet/AdHocCommandData.java
  78. +2
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/delay/packet/DelayInformation.java
  79. +4
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/disco/AbstractNodeInformationProvider.java
  80. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
  81. +3
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java
  82. +4
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FaultTolerantNegotiator.java
  83. +3
    -1
      smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransfer.java
  84. +4
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java
  85. +3
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IncomingFileTransfer.java
  86. +5
    -1
      smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/OutgoingFileTransfer.java
  87. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/geoloc/GeoLocationManager.java
  88. +2
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/LastActivityManager.java
  89. +3
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/packet/DefaultPrivateData.java
  90. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/iqversion/VersionManager.java
  91. +15
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/DefaultParticipantStatusListener.java
  92. +13
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/DefaultUserStatusListener.java
  93. +3
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
  94. +2
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChatManager.java
  95. +2
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/Occupant.java
  96. +2
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/GroupChatInvitation.java
  97. +3
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCInitialPresence.java
  98. +1
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCItem.java
  99. +2
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/packet/MUCUser.java
  100. +3
    -0
      smack-extensions/src/main/java/org/jivesoftware/smackx/nick/packet/Nick.java

+ 1
- 1
build.gradle View File

@@ -170,7 +170,7 @@ allprojects {
// version 52.0" error messages caused by the errorprone javac.
// See https://github.com/tbroyer/gradle-errorprone-plugin/issues/18 for more information.
configurations.errorprone {
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.5'
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.15'
}
}



+ 1
- 0
smack-bosh/src/main/java/org/jivesoftware/smack/bosh/BOSHConfiguration.java View File

@@ -55,6 +55,7 @@ public final class BOSHConfiguration extends ConnectionConfiguration {
return proxy != null;
}

@Override
public ProxyInfo getProxyInfo() {
return proxy;
}


+ 20
- 4
smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java View File

@@ -203,11 +203,13 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
saslFeatureReceived.reportSuccess();
}

@Override
public boolean isSecureConnection() {
// TODO: Implement SSL usage
return false;
}

@Override
public boolean isUsingCompression() {
// TODO: Implement compression
return false;
@@ -313,16 +315,25 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
/**
* Initialize the SmackDebugger which allows to log and debug XML traffic.
*/
@Override
protected void initDebugger() {
// TODO: Maybe we want to extend the SmackDebugger for simplification
// and a performance boost.

// Initialize a empty writer which discards all data.
writer = new Writer() {
public void write(char[] cbuf, int off, int len) { /* ignore */}
public void close() { /* ignore */ }
public void flush() { /* ignore */ }
};
@Override
public void write(char[] cbuf, int off, int len) {
/* ignore */}

@Override
public void close() {
/* ignore */ }

@Override
public void flush() {
/* ignore */ }
};

// Initialize a pipe for received raw data.
try {
@@ -338,6 +349,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {

// Add listeners for the received and sent raw data.
client.addBOSHClientResponseListener(new BOSHClientResponseListener() {
@Override
public void responseReceived(BOSHMessageEvent event) {
if (event.getBody() != null) {
try {
@@ -350,6 +362,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
}
});
client.addBOSHClientRequestListener(new BOSHClientRequestListener() {
@Override
public void requestSent(BOSHMessageEvent event) {
if (event.getBody() != null) {
try {
@@ -366,6 +379,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
private Thread thread = this;
private int bufferLength = 1024;

@Override
public void run() {
try {
char[] cbuf = new char[bufferLength];
@@ -406,6 +420,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
* Process the connection listeners and try to login if the
* connection was formerly authenticated and is now reconnected.
*/
@Override
public void connectionEvent(BOSHClientConnEvent connEvent) {
try {
if (connEvent.isConnected()) {
@@ -463,6 +478,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
*
* @param event the BOSH client response which includes the received packet.
*/
@Override
public void responseReceived(BOSHMessageEvent event) {
AbstractBody body = event.getBody();
if (body != null) {


+ 1
- 0
smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java View File

@@ -1616,6 +1616,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {

private long lastStanzaReceived;

@Override
public long getLastStanzaReceived() {
return lastStanzaReceived;
}


+ 2
- 0
smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java View File

@@ -70,6 +70,7 @@ public final class ReconnectionManager {

static {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
@Override
public void connectionCreated(XMPPConnection connection) {
if (connection instanceof AbstractXMPPConnection) {
ReconnectionManager.getInstanceFor((AbstractXMPPConnection) connection);
@@ -204,6 +205,7 @@ public final class ReconnectionManager {
/**
* The process will try the reconnection until the connection succeed or the user cancel it
*/
@Override
public void run() {
final AbstractXMPPConnection connection = weakRefConnection.get();
if (connection == null) {


+ 3
- 2
smack-core/src/main/java/org/jivesoftware/smack/SmackInitialization.java View File

@@ -37,6 +37,7 @@ import org.jivesoftware.smack.sasl.core.SASLXOauth2Mechanism;
import org.jivesoftware.smack.sasl.core.SCRAMSHA1Mechanism;
import org.jivesoftware.smack.sasl.core.ScramSha1PlusMechanism;
import org.jivesoftware.smack.util.FileUtils;
import org.jivesoftware.smack.util.StringUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
@@ -60,7 +61,7 @@ public final class SmackInitialization {
static {
String smackVersion;
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(FileUtils.getStreamForUrl("classpath:org.jivesoftware.smack/version", null)));
BufferedReader reader = new BufferedReader(new InputStreamReader(FileUtils.getStreamForUrl("classpath:org.jivesoftware.smack/version", null), StringUtils.UTF8));
smackVersion = reader.readLine();
try {
reader.close();
@@ -232,7 +233,7 @@ public final class SmackInitialization {
}
}
if (SmackInitializer.class.isAssignableFrom(initClass)) {
SmackInitializer initializer = (SmackInitializer) initClass.newInstance();
SmackInitializer initializer = (SmackInitializer) initClass.getConstructor().newInstance();
List<Exception> exceptions = initializer.initialize();
if (exceptions == null || exceptions.size() == 0) {
LOGGER.log(Level.FINE, "Loaded SmackInitializer " + className);


+ 16
- 0
smack-core/src/main/java/org/jivesoftware/smack/debugger/AbstractDebugger.java View File

@@ -49,6 +49,7 @@ public abstract class AbstractDebugger implements SmackDebugger {
// Create a special Reader that wraps the main Reader and logs data to the GUI.
this.reader = new ObservableReader(reader);
readerListener = new ReaderListener() {
@Override
public void read(String str) {
log("RECV (" + connection.getConnectionCounter() + "): " + str);
}
@@ -58,6 +59,7 @@ public abstract class AbstractDebugger implements SmackDebugger {
// Create a special Writer that wraps the main Writer and logs data to the GUI.
this.writer = new ObservableWriter(writer);
writerListener = new WriterListener() {
@Override
public void write(String str) {
log("SENT (" + connection.getConnectionCounter() + "): " + str);
}
@@ -68,6 +70,7 @@ public abstract class AbstractDebugger implements SmackDebugger {
// the GUI. This is what we call "interpreted" packet data, since it's the packet
// data as Smack sees it and not as it's coming in as raw XML.
listener = new StanzaListener() {
@Override
public void processStanza(Stanza packet) {
if (printInterpreted) {
log("RCV PKT (" + connection.getConnectionCounter() + "): " + packet.toXML());
@@ -76,10 +79,12 @@ public abstract class AbstractDebugger implements SmackDebugger {
};

connListener = new ConnectionListener() {
@Override
public void connected(XMPPConnection connection) {
log("XMPPConnection connected ("
+ connection + ")");
}
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {
String logString = "XMPPConnection authenticated (" + connection + ")";
if (resumed) {
@@ -87,6 +92,7 @@ public abstract class AbstractDebugger implements SmackDebugger {
}
log(logString);
}
@Override
public void connectionClosed() {
log(
"XMPPConnection closed (" +
@@ -94,24 +100,28 @@ public abstract class AbstractDebugger implements SmackDebugger {
")");
}

@Override
public void connectionClosedOnError(Exception e) {
log(
"XMPPConnection closed due to an exception (" +
connection +
")", e);
}
@Override
public void reconnectionFailed(Exception e) {
log(
"Reconnection failed due to an exception (" +
connection +
")", e);
}
@Override
public void reconnectionSuccessful() {
log(
"XMPPConnection reconnected (" +
connection +
")");
}
@Override
public void reconnectingIn(int seconds) {
log(
"XMPPConnection (" +
@@ -125,6 +135,7 @@ public abstract class AbstractDebugger implements SmackDebugger {

protected abstract void log(String logMessage, Throwable throwable);

@Override
public Reader newConnectionReader(Reader newReader) {
reader.removeReaderListener(readerListener);
ObservableReader debugReader = new ObservableReader(newReader);
@@ -133,6 +144,7 @@ public abstract class AbstractDebugger implements SmackDebugger {
return reader;
}

@Override
public Writer newConnectionWriter(Writer newWriter) {
writer.removeWriterListener(writerListener);
ObservableWriter debugWriter = new ObservableWriter(newWriter);
@@ -159,18 +171,22 @@ public abstract class AbstractDebugger implements SmackDebugger {
connection.addConnectionListener(connListener);
}

@Override
public Reader getReader() {
return reader;
}

@Override
public Writer getWriter() {
return writer;
}

@Override
public StanzaListener getReaderListener() {
return listener;
}

@Override
public StanzaListener getWriterListener() {
return null;
}


+ 2
- 0
smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractFromToMatchesFilter.java View File

@@ -47,6 +47,7 @@ public abstract class AbstractFromToMatchesFilter implements StanzaFilter {
this.ignoreResourcepart = ignoreResourcepart;
}

@Override
public final boolean accept(final Stanza stanza) {
Jid stanzaAddress = getAddressToCompare(stanza);

@@ -63,6 +64,7 @@ public abstract class AbstractFromToMatchesFilter implements StanzaFilter {

protected abstract Jid getAddressToCompare(Stanza stanza);

@Override
public final String toString() {
String matchMode = ignoreResourcepart ? "ignoreResourcepart" : "full";
return getClass().getSimpleName() + " (" + matchMode + "): " + address;


+ 1
- 0
smack-core/src/main/java/org/jivesoftware/smack/filter/AndFilter.java View File

@@ -44,6 +44,7 @@ public class AndFilter extends AbstractListFilter implements StanzaFilter {
super(filters);
}

@Override
public boolean accept(Stanza packet) {
for (StanzaFilter filter : filters) {
if (!filter.accept(packet)) {


+ 1
- 0
smack-core/src/main/java/org/jivesoftware/smack/filter/NotFilter.java View File

@@ -39,6 +39,7 @@ public class NotFilter implements StanzaFilter {
this.filter = Objects.requireNonNull(filter, "Parameter must not be null.");
}

@Override
public boolean accept(Stanza packet) {
return !filter.accept(packet);
}


+ 1
- 0
smack-core/src/main/java/org/jivesoftware/smack/filter/PacketExtensionFilter.java View File

@@ -67,6 +67,7 @@ public class PacketExtensionFilter implements StanzaFilter {
this(packetExtension.getElementName(), packetExtension.getNamespace());
}

@Override
public boolean accept(Stanza packet) {
return packet.hasExtension(elementName, namespace);
}


+ 2
- 0
smack-core/src/main/java/org/jivesoftware/smack/filter/PacketIDFilter.java View File

@@ -54,10 +54,12 @@ public class PacketIDFilter implements StanzaFilter {
this.packetID = packetID;
}

@Override
public boolean accept(Stanza packet) {
return packetID.equals(packet.getStanzaId());
}

@Override
public String toString() {
return getClass().getSimpleName() + ": id=" + packetID;
}


+ 1
- 0
smack-core/src/main/java/org/jivesoftware/smack/filter/PacketTypeFilter.java View File

@@ -51,6 +51,7 @@ public class PacketTypeFilter implements StanzaFilter {
this.packetType = packetType;
}

@Override
public boolean accept(Stanza packet) {
return packetType.isInstance(packet);
}


+ 1
- 0
smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaExtensionFilter.java View File

@@ -65,6 +65,7 @@ public class StanzaExtensionFilter implements StanzaFilter {
this(packetExtension.getElementName(), packetExtension.getNamespace());
}

@Override
public boolean accept(Stanza packet) {
return packet.hasExtension(elementName, namespace);
}


+ 2
- 0
smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaIdFilter.java View File

@@ -47,10 +47,12 @@ public class StanzaIdFilter implements StanzaFilter {
this.stanzaId = StringUtils.requireNotNullOrEmpty(stanzaID, "Stanza ID must not be null or empty.");
}

@Override
public boolean accept(Stanza stanza) {
return stanzaId.equals(stanza.getStanzaId());
}

@Override
public String toString() {
return getClass().getSimpleName() + ": id=" + stanzaId;
}


+ 1
- 0
smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaTypeFilter.java View File

@@ -51,6 +51,7 @@ public final class StanzaTypeFilter implements StanzaFilter {
this.packetType = packetType;
}

@Override
public boolean accept(Stanza packet) {
return packetType.isInstance(packet);
}


+ 2
- 0
smack-core/src/main/java/org/jivesoftware/smack/packet/DefaultExtensionElement.java View File

@@ -70,6 +70,7 @@ public class DefaultExtensionElement implements ExtensionElement {
*
* @return the XML element name of the stanza(/packet) extension.
*/
@Override
public String getElementName() {
return elementName;
}
@@ -79,6 +80,7 @@ public class DefaultExtensionElement implements ExtensionElement {
*
* @return the XML namespace of the stanza(/packet) extension.
*/
@Override
public String getNamespace() {
return namespace;
}


+ 4
- 0
smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java View File

@@ -570,6 +570,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
}


@Override
public int hashCode() {
final int prime = 31;
int result = 1;
@@ -578,6 +579,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
@@ -632,6 +634,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
return message;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
@@ -640,6 +643,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;


+ 1
- 1
smack-core/src/main/java/org/jivesoftware/smack/provider/IntrospectionProvider.java View File

@@ -78,7 +78,7 @@ public class IntrospectionProvider{
IOException, IllegalArgumentException, InvocationTargetException,
ClassNotFoundException {
ParserUtils.assertAtStartTag(parser);
Object object = objectClass.newInstance();
Object object = objectClass.getConstructor().newInstance();
outerloop: while (true) {
int eventType = parser.next();
switch (eventType) {


+ 7
- 3
smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderFileLoader.java View File

@@ -83,7 +83,8 @@ public class ProviderFileLoader implements ProviderLoader {
// reflection later to create instances of the class.
// Add the provider to the map.
if (IQProvider.class.isAssignableFrom(provider)) {
iqProviders.add(new IQProviderInfo(elementName, namespace, (IQProvider<IQ>) provider.newInstance()));
IQProvider<IQ> iqProvider = (IQProvider<IQ>) provider.getConstructor().newInstance();
iqProviders.add(new IQProviderInfo(elementName, namespace, iqProvider));
}
else {
exceptions.add(new IllegalArgumentException(className + " is not a IQProvider"));
@@ -96,7 +97,9 @@ public class ProviderFileLoader implements ProviderLoader {
// then we'll use reflection later to create instances
// of the class.
if (ExtensionElementProvider.class.isAssignableFrom(provider)) {
extProviders.add(new ExtensionProviderInfo(elementName, namespace, (ExtensionElementProvider<ExtensionElement>) provider.newInstance()));
ExtensionElementProvider<ExtensionElement> extensionElementProvider = (ExtensionElementProvider<ExtensionElement>) provider.getConstructor().newInstance();
extProviders.add(new ExtensionProviderInfo(elementName, namespace,
extensionElementProvider));
}
else {
exceptions.add(new IllegalArgumentException(className
@@ -104,9 +107,10 @@ public class ProviderFileLoader implements ProviderLoader {
}
break;
case "streamFeatureProvider":
ExtensionElementProvider<ExtensionElement> streamFeatureProvider = (ExtensionElementProvider<ExtensionElement>) provider.getConstructor().newInstance();
sfProviders.add(new StreamFeatureProviderInfo(elementName,
namespace,
(ExtensionElementProvider<ExtensionElement>) provider.newInstance()));
streamFeatureProvider));
break;
default:
LOGGER.warning("Unknown provider type: " + typeName);


+ 4
- 1
smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks4ProxySocketConnection.java View File

@@ -23,6 +23,8 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;

import org.jivesoftware.smack.util.StringUtils;

/**
* Socket factory for socks4 proxy.
*
@@ -89,7 +91,8 @@ public class Socks4ProxySocketConnection implements ProxySocketConnection {

if(user!=null)
{
System.arraycopy(user.getBytes(), 0, buf, index, user.length());
byte[] userBytes = user.getBytes(StringUtils.UTF8);
System.arraycopy(userBytes, 0, buf, index, user.length());
index+=user.length();
}
buf[index++]=0;


+ 8
- 4
smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks5ProxySocketConnection.java View File

@@ -22,6 +22,8 @@ import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;

import org.jivesoftware.smack.util.StringUtils;

/**
* Socket factory for Socks5 proxy.
*
@@ -132,11 +134,13 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection {
index=0;
buf[index++]=1;
buf[index++]=(byte)(user.length());
System.arraycopy(user.getBytes(), 0, buf, index,
byte[] userBytes = user.getBytes(StringUtils.UTF8);
System.arraycopy(userBytes, 0, buf, index,
user.length());
index+=user.length();
buf[index++]=(byte)(passwd.length());
System.arraycopy(passwd.getBytes(), 0, buf, index,
byte[] passwordBytes = user.getBytes(StringUtils.UTF8);
buf[index++]=(byte)(passwordBytes.length);
System.arraycopy(passwordBytes, 0, buf, index,
passwd.length());
index+=passwd.length();

@@ -210,7 +214,7 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection {
buf[index++]=1; // CONNECT
buf[index++]=0;

byte[] hostb= host.getBytes();
byte[] hostb= host.getBytes(StringUtils.UTF8);
int len=hostb.length;
buf[index++]=3; // DOMAINNAME
buf[index++]=(byte)(len);


+ 3
- 2
smack-core/src/main/java/org/jivesoftware/smack/sasl/SASLMechanism.java View File

@@ -265,9 +265,10 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
return null;
}

@Override
public final int compareTo(SASLMechanism other) {
// Switch to Integer.compare(int, int) once Smack is on Android 19 or higher.
Integer ourPriority = new Integer(getPriority());
Integer ourPriority = getPriority();
return ourPriority.compareTo(other.getPriority());
}

@@ -300,7 +301,7 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
}

/**
* SASLprep the given String.
* SASLprep the given String. The resulting String is in UTF-8.
*
* @param string the String to sasl prep.
* @return the given String SASL preped


+ 1
- 0
smack-core/src/main/java/org/jivesoftware/smack/sasl/core/SASLAnonymous.java View File

@@ -30,6 +30,7 @@ public class SASLAnonymous extends SASLMechanism {

public static final String NAME = "ANONYMOUS";

@Override
public String getName() {
return NAME;
}


+ 20
- 4
smack-core/src/main/java/org/jivesoftware/smack/sasl/core/ScramMechanism.java View File

@@ -16,6 +16,7 @@
*/
package org.jivesoftware.smack.sasl.core;

import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.SecureRandom;
import java.util.Collections;
@@ -105,7 +106,15 @@ public abstract class ScramMechanism extends SASLMechanism {

@Override
protected byte[] evaluateChallenge(byte[] challenge) throws SmackException {
final String challengeString = new String(challenge);
String challengeString;
try {
// TODO: Where is it specified that this is an UTF-8 encoded string?
challengeString = new String(challenge, StringUtils.UTF8);
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}

switch (state) {
case AUTH_TEXT_SENT:
final String serverFirstMessage = challengeString;
@@ -358,14 +367,21 @@ public abstract class ScramMechanism extends SASLMechanism {
* (PRF) and with dkLen == output length of HMAC() == output length of H().
* </p>
*
* @param str
* @param normalizedPassword the normalized password.
* @param salt
* @param iterations
* @return the result of the Hi function.
* @throws SmackException
*/
private byte[] hi(String str, byte[] salt, int iterations) throws SmackException {
byte[] key = str.getBytes();
private byte[] hi(String normalizedPassword, byte[] salt, int iterations) throws SmackException {
byte[] key;
try {
// According to RFC 5802 § 2.2, the resulting string of the normalization is also in UTF-8.
key = normalizedPassword.getBytes(StringUtils.UTF8);
}
catch (UnsupportedEncodingException e) {
throw new AssertionError();
}
// U1 := HMAC(str, salt + INT(1))
byte[] u = hmac(key, ByteUtils.concact(salt, ONE));
byte[] res = u.clone();


+ 4
- 0
smack-core/src/main/java/org/jivesoftware/smack/util/ArrayBlockingQueueWithShutdown.java View File

@@ -240,6 +240,7 @@ public class ArrayBlockingQueueWithShutdown<E> extends AbstractQueue<E> implemen
* @param e the element to add.
* @throws InterruptedException if interrupted while waiting or if the queue was shut down.
*/
@Override
public void put(E e) throws InterruptedException {
checkNotNull(e);
lock.lockInterruptibly();
@@ -452,6 +453,7 @@ public class ArrayBlockingQueueWithShutdown<E> extends AbstractQueue<E> implemen
}
}

@Override
public boolean hasNext() {
return nextIndex >= 0;
}
@@ -469,6 +471,7 @@ public class ArrayBlockingQueueWithShutdown<E> extends AbstractQueue<E> implemen
}
}

@Override
public E next() {
lock.lock();
try {
@@ -486,6 +489,7 @@ public class ArrayBlockingQueueWithShutdown<E> extends AbstractQueue<E> implemen
}
}

@Override
public void remove() {
lock.lock();
try {


+ 4
- 1
smack-core/src/main/java/org/jivesoftware/smack/util/FileUtils.java View File

@@ -87,7 +87,8 @@ public final class FileUtils {
public static boolean addLines(String url, Set<String> set) throws MalformedURLException, IOException {
InputStream is = getStreamForUrl(url, null);
if (is == null) return false;
BufferedReader br = new BufferedReader(new InputStreamReader(is));
InputStreamReader sr = new InputStreamReader(is, StringUtils.UTF8);
BufferedReader br = new BufferedReader(sr);
String line;
while ((line = br.readLine()) != null) {
set.add(line);
@@ -102,6 +103,7 @@ public final class FileUtils {
* @return the content of file or null in case of an error
* @throws IOException
*/
@SuppressWarnings("DefaultCharset")
public static String readFileOrThrow(File file) throws FileNotFoundException, IOException {
Reader reader = null;
try {
@@ -132,6 +134,7 @@ public final class FileUtils {
return null;
}

@SuppressWarnings("DefaultCharset")
public static void writeFileOrThrow(File file, CharSequence content) throws IOException {
FileWriter writer = new FileWriter(file, false);
try {


+ 9
- 0
smack-core/src/main/java/org/jivesoftware/smack/util/ObservableReader.java View File

@@ -37,6 +37,7 @@ public class ObservableReader extends Reader {
this.wrappedReader = wrappedReader;
}

@Override
public int read(char[] cbuf, int off, int len) throws IOException {
int count = wrappedReader.read(cbuf, off, len);
if (count > 0) {
@@ -54,34 +55,42 @@ public class ObservableReader extends Reader {
return count;
}

@Override
public void close() throws IOException {
wrappedReader.close();
}

@Override
public int read() throws IOException {
return wrappedReader.read();
}

@Override
public int read(char[] cbuf) throws IOException {
return wrappedReader.read(cbuf);
}

@Override
public long skip(long n) throws IOException {
return wrappedReader.skip(n);
}

@Override
public boolean ready() throws IOException {
return wrappedReader.ready();
}

@Override
public boolean markSupported() {
return wrappedReader.markSupported();
}

@Override
public void mark(int readAheadLimit) throws IOException {
wrappedReader.mark(readAheadLimit);
}

@Override
public void reset() throws IOException {
wrappedReader.reset();
}


+ 7
- 0
smack-core/src/main/java/org/jivesoftware/smack/util/ObservableWriter.java View File

@@ -38,36 +38,43 @@ public class ObservableWriter extends Writer {
this.wrappedWriter = wrappedWriter;
}

@Override
public void write(char[] cbuf, int off, int len) throws IOException {
wrappedWriter.write(cbuf, off, len);
String str = new String(cbuf, off, len);
maybeNotifyListeners(str);
}

@Override
public void flush() throws IOException {
notifyListeners();
wrappedWriter.flush();
}

@Override
public void close() throws IOException {
wrappedWriter.close();
}

@Override
public void write(int c) throws IOException {
wrappedWriter.write(c);
}

@Override
public void write(char[] cbuf) throws IOException {
wrappedWriter.write(cbuf);
String str = new String(cbuf);
maybeNotifyListeners(str);
}

@Override
public void write(String str) throws IOException {
wrappedWriter.write(str);
maybeNotifyListeners(str);
}

@Override
public void write(String str, int off, int len) throws IOException {
wrappedWriter.write(str, off, len);
str = str.substring(off, off + len);


+ 33
- 4
smack-core/src/main/java/org/jivesoftware/smack/util/stringencoder/Base32.java View File

@@ -20,6 +20,9 @@ package org.jivesoftware.smack.util.stringencoder;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

import org.jivesoftware.smack.util.StringUtils;

/**
* Base32 string encoding is useful for when filenames case-insensitive filesystems are encoded.
@@ -53,7 +56,13 @@ public class Base32 {

public static String decode(String str) {
ByteArrayOutputStream bs = new ByteArrayOutputStream();
byte[] raw = str.getBytes();
byte[] raw;
try {
raw = str.getBytes(StringUtils.UTF8);
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
for (int i = 0; i < raw.length; i++) {
char c = (char) raw[i];
if (!Character.isWhitespace(c)) {
@@ -106,11 +115,24 @@ public class Base32 {
}
}

return new String(bs.toByteArray());
String res;
try {
res = new String(bs.toByteArray(), StringUtils.UTF8);
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
return res;
}

public static String encode(String str) {
byte[] b = str.getBytes();
byte[] b;
try {
b = str.getBytes(StringUtils.UTF8);
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
ByteArrayOutputStream os = new ByteArrayOutputStream();

for (int i = 0; i < (b.length + 4) / 5; i++) {
@@ -153,7 +175,14 @@ public class Base32 {
os.write(c);
}
}
return new String(os.toByteArray());
String res;
try {
res = new String(os.toByteArray(), StringUtils.UTF8);
}
catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
return res;
}

private static int lenToPadding(int blocklen) {


+ 1
- 0
smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java View File

@@ -180,6 +180,7 @@ public class DummyConnection extends AbstractXMPPConnection {
*
* @param packet the stanza(/packet) to process.
*/
@Override
public void processStanza(Stanza packet) {
invokeStanzaCollectorsAndNotifyRecvListeners(packet);
}


+ 3
- 3
smack-core/src/test/java/org/jivesoftware/smack/StanzaCollectorTest.java View File

@@ -176,7 +176,7 @@ public class StanzaCollectorTest
assertNull(collector.pollResult());
}

class OKEverything implements StanzaFilter
static class OKEverything implements StanzaFilter
{
@Override
public boolean accept(Stanza packet)
@@ -186,7 +186,7 @@ public class StanzaCollectorTest

}

class TestStanzaCollector extends StanzaCollector
static class TestStanzaCollector extends StanzaCollector
{
protected TestStanzaCollector(XMPPConnection conection, StanzaFilter packetFilter, int size)
{
@@ -194,7 +194,7 @@ public class StanzaCollectorTest
}
}

class TestPacket extends Stanza
static class TestPacket extends Stanza
{
public TestPacket(int i)
{


+ 3
- 2
smack-core/src/test/java/org/jivesoftware/smack/sasl/DigestMd5SaslTest.java View File

@@ -19,6 +19,7 @@ package org.jivesoftware.smack.sasl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

@@ -38,14 +39,14 @@ public class DigestMd5SaslTest extends AbstractSaslTest {
super(saslMechanism);
}

protected void runTest(boolean useAuthzid) throws NotConnectedException, SmackException, InterruptedException, XmppStringprepException {
protected void runTest(boolean useAuthzid) throws NotConnectedException, SmackException, InterruptedException, XmppStringprepException, UnsupportedEncodingException {
EntityBareJid authzid = null;
if (useAuthzid) {
authzid = JidCreate.entityBareFrom("shazbat@xmpp.org");
}
saslMechanism.authenticate("florian", "irrelevant", JidCreate.domainBareFrom("xmpp.org"), "secret", authzid, null);
byte[] response = saslMechanism.evaluateChallenge(challengeBytes);
String responseString = new String(response);
String responseString = new String(response, StringUtils.UTF8);
String[] responseParts = responseString.split(",");
Map<String, String> responsePairs = new HashMap<String, String>();
for (String part : responseParts) {


+ 1
- 0
smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java View File

@@ -851,6 +851,7 @@ public class PacketParserUtilsTest {
XmlUnitUtils.assertSimilar(saslFailureString, saslFailure.toXML());
}

@SuppressWarnings("ReferenceEquality")
private static String determineNonDefaultLanguage() {
String otherLanguage = "jp";
Locale[] availableLocales = Locale.getAvailableLocales();


+ 7
- 5
smack-core/src/test/java/org/jivesoftware/smack/util/StringUtilsTest.java View File

@@ -21,6 +21,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.io.UnsupportedEncodingException;

import org.junit.Test;

/**
@@ -72,16 +74,16 @@ public class StringUtilsTest {
}

@Test
public void testEncodeHex() {
public void testEncodeHex() throws UnsupportedEncodingException {
String input = "";
String output = "";
assertEquals(new String(StringUtils.encodeHex(input.getBytes())),
new String(output.getBytes()));
assertEquals(new String(StringUtils.encodeHex(input.getBytes(StringUtils.UTF8))),
output);

input = "foo bar 123";
output = "666f6f2062617220313233";
assertEquals(new String(StringUtils.encodeHex(input.getBytes())),
new String(output.getBytes()));
assertEquals(new String(StringUtils.encodeHex(input.getBytes(StringUtils.UTF8))),
output);
}

@Test


+ 5
- 0
smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JLoggingConnectionListener.java View File

@@ -40,22 +40,27 @@ class SLF4JLoggingConnectionListener implements ConnectionListener {
logger.debug("({}) Connection authenticated as {}", connection.hashCode(), connection.getUser());
}

@Override
public void connectionClosed() {
logger.debug("({}) Connection closed", connection.hashCode());
}

@Override
public void connectionClosedOnError(Exception e) {
logger.debug("({}) Connection closed due to an exception: {}", connection.hashCode(), e);
}

@Override
public void reconnectionFailed(Exception e) {
logger.debug("({}) Reconnection failed due to an exception: {}", connection.hashCode(), e);
}

@Override
public void reconnectionSuccessful() {
logger.debug("({}) Connection reconnected", connection.hashCode());
}

@Override
public void reconnectingIn(int seconds) {
logger.debug("({}) Connection will reconnect in {}", connection.hashCode(), seconds);
}


+ 1
- 0
smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JLoggingPacketListener.java View File

@@ -31,6 +31,7 @@ class SLF4JLoggingPacketListener implements StanzaListener {
this.prefix = Validate.notNull(prefix);
}

@Override
public void processStanza(Stanza packet) {
if (SLF4JSmackDebugger.printInterpreted.get() && logger.isDebugEnabled()) {
logger.debug("{}: PKT [{}] '{}'", prefix, packet.getClass().getName(), packet.toXML());


+ 2
- 0
smack-debug-slf4j/src/main/java/org/jivesoftware/smackx/debugger/slf4j/SLF4JRawXmlListener.java View File

@@ -28,10 +28,12 @@ class SLF4JRawXmlListener implements ReaderListener, WriterListener {
this.logger = Validate.notNull(logger);
}

@Override
public void read(String str) {
logger.debug("{}: {}", SLF4JSmackDebugger.RECEIVED_TAG, str);
}

@Override
public void write(String str) {
logger.debug("{}: {}", SLF4JSmackDebugger.SENT_TAG, str);
}


+ 50
- 5
smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java View File

@@ -208,8 +208,10 @@ public class EnhancedDebugger implements SmackDebugger {
packetReaderListener = new StanzaListener() {
SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss:SS");

@Override
public void processStanza(final Stanza packet) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
addReadPacketToTable(dateFormatter, packet);
}
@@ -223,8 +225,10 @@ public class EnhancedDebugger implements SmackDebugger {
packetWriterListener = new StanzaListener() {
SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss:SS");

@Override
public void processStanza(final Stanza packet) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
addSentPacketToTable(dateFormatter, packet);
}
@@ -235,8 +239,10 @@ public class EnhancedDebugger implements SmackDebugger {

// Create a thread that will listen for any connection closed event
connListener = new AbstractConnectionListener() {
@Override
public void connectionClosed() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
statusField.setValue("Closed");
EnhancedDebuggerWindow.connectionClosed(EnhancedDebugger.this);
@@ -245,8 +251,10 @@ public class EnhancedDebugger implements SmackDebugger {

}

@Override
public void connectionClosedOnError(final Exception e) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
statusField.setValue("Closed due to an exception");
EnhancedDebuggerWindow.connectionClosedOnError(EnhancedDebugger.this, e);
@@ -254,16 +262,20 @@ public class EnhancedDebugger implements SmackDebugger {
});

}
@Override
public void reconnectingIn(final int seconds){
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
statusField.setValue("Attempt to reconnect in " + seconds + " seconds");
}
});
}

@Override
public void reconnectionSuccessful() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
statusField.setValue("Reconnection stablished");
EnhancedDebuggerWindow.connectionEstablished(EnhancedDebugger.this);
@@ -271,8 +283,10 @@ public class EnhancedDebugger implements SmackDebugger {
});
}

@Override
public void reconnectionFailed(Exception e) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
statusField.setValue("Reconnection failed");
}
@@ -291,11 +305,13 @@ public class EnhancedDebugger implements SmackDebugger {
0) {
// CHECKSTYLE:OFF
private static final long serialVersionUID = 8136121224474217264L;
public boolean isCellEditable(int rowIndex, int mColIndex) {
@Override
public boolean isCellEditable(int rowIndex, int mColIndex) {
// CHECKSTYLE:ON
return false;
}

@Override
public Class<?> getColumnClass(int columnIndex) {
if (columnIndex == 2 || columnIndex == 3) {
return Icon.class;
@@ -344,6 +360,7 @@ public class EnhancedDebugger implements SmackDebugger {
JPopupMenu menu = new JPopupMenu();
JMenuItem menuItem1 = new JMenuItem("Copy");
menuItem1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Get the clipboard
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
@@ -391,6 +408,7 @@ public class EnhancedDebugger implements SmackDebugger {
menu = new JPopupMenu();
menuItem1 = new JMenuItem("Copy");
menuItem1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Get the clipboard
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
@@ -401,6 +419,7 @@ public class EnhancedDebugger implements SmackDebugger {

JMenuItem menuItem2 = new JMenuItem("Clear");
menuItem2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
sentText.setText("");
}
@@ -426,6 +445,7 @@ public class EnhancedDebugger implements SmackDebugger {
menu = new JPopupMenu();
menuItem1 = new JMenuItem("Copy");
menuItem1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Get the clipboard
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
@@ -436,6 +456,7 @@ public class EnhancedDebugger implements SmackDebugger {

menuItem2 = new JMenuItem("Clear");
menuItem2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
receivedText.setText("");
}
@@ -449,8 +470,10 @@ public class EnhancedDebugger implements SmackDebugger {
// Create a special Reader that wraps the main Reader and logs data to the GUI.
ObservableReader debugReader = new ObservableReader(reader);
readerListener = new ReaderListener() {
@Override
public void read(final String str) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER &&
!EnhancedDebuggerWindow.getInstance().isVisible()) {
@@ -487,8 +510,10 @@ public class EnhancedDebugger implements SmackDebugger {
// Create a special Writer that wraps the main Writer and logs data to the GUI.
ObservableWriter debugWriter = new ObservableWriter(writer);
writerListener = new WriterListener() {
@Override
public void write(final String str) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER &&
!EnhancedDebuggerWindow.getInstance().isVisible()) {
@@ -536,6 +561,7 @@ public class EnhancedDebugger implements SmackDebugger {
JPopupMenu menu = new JPopupMenu();
JMenuItem menuItem = new JMenuItem("Message");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
adhocMessages.setText(
"<message to=\"\" id=\""
@@ -547,6 +573,7 @@ public class EnhancedDebugger implements SmackDebugger {

menuItem = new JMenuItem("IQ Get");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
adhocMessages.setText(
"<iq type=\"get\" to=\"\" id=\""
@@ -558,6 +585,7 @@ public class EnhancedDebugger implements SmackDebugger {

menuItem = new JMenuItem("IQ Set");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
adhocMessages.setText(
"<iq type=\"set\" to=\"\" id=\""
@@ -569,6 +597,7 @@ public class EnhancedDebugger implements SmackDebugger {

menuItem = new JMenuItem("Presence");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
adhocMessages.setText(
"<presence to=\"\" id=\"" + StringUtils.randomString(5) + "-X\"/>");
@@ -579,6 +608,7 @@ public class EnhancedDebugger implements SmackDebugger {

menuItem = new JMenuItem("Send");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!"".equals(adhocMessages.getText())) {
AdHocPacket packetToSend = new AdHocPacket(adhocMessages.getText());
@@ -595,6 +625,7 @@ public class EnhancedDebugger implements SmackDebugger {

menuItem = new JMenuItem("Clear");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
adhocMessages.setText(null);
}
@@ -709,7 +740,8 @@ public class EnhancedDebugger implements SmackDebugger {
new Object[]{"Type", "Received", "Sent"}) {
// CHECKSTYLE:OFF
private static final long serialVersionUID = -6793886085109589269L;
public boolean isCellEditable(int rowIndex, int mColIndex) {
@Override
public boolean isCellEditable(int rowIndex, int mColIndex) {
// CHECKSTYLE:ON
return false;
}
@@ -726,6 +758,7 @@ public class EnhancedDebugger implements SmackDebugger {
tabbedPane.setToolTipTextAt(4, "Information and statistics about the debugged connection");
}

@Override
public Reader newConnectionReader(Reader newReader) {
((ObservableReader) reader).removeReaderListener(readerListener);
ObservableReader debugReader = new ObservableReader(newReader);
@@ -734,6 +767,7 @@ public class EnhancedDebugger implements SmackDebugger {
return reader;
}

@Override
public Writer newConnectionWriter(Writer newWriter) {
((ObservableWriter) writer).removeWriterListener(writerListener);
ObservableWriter debugWriter = new ObservableWriter(newWriter);
@@ -746,6 +780,7 @@ public class EnhancedDebugger implements SmackDebugger {
public void userHasLogged(final EntityFullJid user) {
final EnhancedDebugger debugger = this;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
userField.setText(user.toString());
EnhancedDebuggerWindow.userHasLogged(debugger, user.toString());
@@ -757,18 +792,22 @@ public class EnhancedDebugger implements SmackDebugger {

}

@Override
public Reader getReader() {
return reader;
}

@Override
public Writer getWriter() {
return writer;
}

@Override
public StanzaListener getReaderListener() {
return packetReaderListener;
}

@Override
public StanzaListener getWriterListener() {
return packetWriterListener;
}
@@ -801,6 +840,7 @@ public class EnhancedDebugger implements SmackDebugger {
*/
private void addReadPacketToTable(final SimpleDateFormat dateFormatter, final Stanza packet) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String messageType;
Jid from = packet.getFrom();
@@ -862,6 +902,7 @@ public class EnhancedDebugger implements SmackDebugger {
*/
private void addSentPacketToTable(final SimpleDateFormat dateFormatter, final Stanza packet) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String messageType;
Jid to = packet.getTo();
@@ -978,9 +1019,9 @@ public class EnhancedDebugger implements SmackDebugger {
* The whole text to send must be passed to the constructor. This implies that the client of
* this class is responsible for sending a valid text to the constructor.
*/
private class AdHocPacket extends Stanza {
private static class AdHocPacket extends Stanza {

private String text;
private final String text;

/**
* Create a new AdHocPacket with the text to send. The passed text must be a valid text to
@@ -992,6 +1033,7 @@ public class EnhancedDebugger implements SmackDebugger {
this.text = text;
}

@Override
public String toXML() {
return text;
}
@@ -1006,7 +1048,7 @@ public class EnhancedDebugger implements SmackDebugger {
/**
* Listens for debug window popup dialog events.
*/
private class PopupListener extends MouseAdapter {
private static class PopupListener extends MouseAdapter {

JPopupMenu popup;

@@ -1014,10 +1056,12 @@ public class EnhancedDebugger implements SmackDebugger {
popup = popupMenu;
}

@Override
public void mousePressed(MouseEvent e) {
maybeShowPopup(e);
}

@Override
public void mouseReleased(MouseEvent e) {
maybeShowPopup(e);
}
@@ -1039,6 +1083,7 @@ public class EnhancedDebugger implements SmackDebugger {
this.table = table;
}

@Override
public void valueChanged(ListSelectionEvent e) {
if (table.getSelectedRow() == -1) {
// Clear the messageTextArea since there is none packet selected


+ 7
- 2
smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java View File

@@ -210,6 +210,7 @@ public final class EnhancedDebuggerWindow {
if (!PERSISTED_DEBUGGER) {
// Add listener for window closing event
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
rootWindowClosing(evt);
}
@@ -280,6 +281,7 @@ public final class EnhancedDebuggerWindow {
// Add a menu item that allows to close the current selected tab
JMenuItem menuItem = new JMenuItem("Close");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Remove the selected tab pane if it's not the Smack info pane
if (tabbedPane.getSelectedIndex() < tabbedPane.getComponentCount() - 1) {
@@ -301,6 +303,7 @@ public final class EnhancedDebuggerWindow {
// Add a menu item that allows to close all the tabs that have their connections closed
menuItem = new JMenuItem("Close All Not Active");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ArrayList<EnhancedDebugger> debuggersToRemove = new ArrayList<EnhancedDebugger>();
// Remove all the debuggers of which their connections are no longer valid
@@ -348,7 +351,7 @@ public final class EnhancedDebuggerWindow {
debugger.cancel();
}
// Release any reference to the debuggers
debuggers.removeAll(debuggers);
debuggers.clear();
// Release the default instance
instance = null;
}
@@ -356,7 +359,7 @@ public final class EnhancedDebuggerWindow {
/**
* Listens for debug window popup dialog events.
*/
private class PopupListener extends MouseAdapter {
private static class PopupListener extends MouseAdapter {

JPopupMenu popup;

@@ -364,10 +367,12 @@ public final class EnhancedDebuggerWindow {
popup = popupMenu;
}

@Override
public void mousePressed(MouseEvent e) {
maybeShowPopup(e);
}

@Override
public void mouseReleased(MouseEvent e) {
maybeShowPopup(e);
}


+ 19
- 1
smack-debug/src/main/java/org/jivesoftware/smackx/debugger/LiteDebugger.java View File

@@ -86,6 +86,7 @@ public class LiteDebugger implements SmackDebugger {

// Add listener for window closing event
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
rootWindowClosing(evt);
}
@@ -114,6 +115,7 @@ public class LiteDebugger implements SmackDebugger {
JPopupMenu menu = new JPopupMenu();
JMenuItem menuItem1 = new JMenuItem("Copy");
menuItem1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Get the clipboard
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
@@ -124,6 +126,7 @@ public class LiteDebugger implements SmackDebugger {

JMenuItem menuItem2 = new JMenuItem("Clear");
menuItem2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
sentText1.setText("");
sentText2.setText("");
@@ -151,6 +154,7 @@ public class LiteDebugger implements SmackDebugger {
menu = new JPopupMenu();
menuItem1 = new JMenuItem("Copy");
menuItem1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Get the clipboard
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
@@ -161,6 +165,7 @@ public class LiteDebugger implements SmackDebugger {

menuItem2 = new JMenuItem("Clear");
menuItem2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
receivedText1.setText("");
receivedText2.setText("");
@@ -188,6 +193,7 @@ public class LiteDebugger implements SmackDebugger {
menu = new JPopupMenu();
menuItem1 = new JMenuItem("Copy");
menuItem1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Get the clipboard
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
@@ -198,6 +204,7 @@ public class LiteDebugger implements SmackDebugger {

menuItem2 = new JMenuItem("Clear");
menuItem2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
interpretedText1.setText("");
interpretedText2.setText("");
@@ -219,6 +226,7 @@ public class LiteDebugger implements SmackDebugger {
// Create a special Reader that wraps the main Reader and logs data to the GUI.
ObservableReader debugReader = new ObservableReader(reader);
readerListener = new ReaderListener() {
@Override
public void read(String str) {
int index = str.lastIndexOf(">");
if (index != -1) {
@@ -242,6 +250,7 @@ public class LiteDebugger implements SmackDebugger {
// Create a special Writer that wraps the main Writer and logs data to the GUI.
ObservableWriter debugWriter = new ObservableWriter(writer);
writerListener = new WriterListener() {
@Override
public void write(String str) {
sentText1.append(str);
sentText2.append(str);
@@ -262,6 +271,7 @@ public class LiteDebugger implements SmackDebugger {
// the GUI. This is what we call "interpreted" packet data, since it's the packet
// data as Smack sees it and not as it's coming in as raw XML.
listener = new StanzaListener() {
@Override
public void processStanza(Stanza packet) {
interpretedText1.append(packet.toXML().toString());
interpretedText2.append(packet.toXML().toString());
@@ -286,17 +296,19 @@ public class LiteDebugger implements SmackDebugger {
/**
* Listens for debug window popup dialog events.
*/
private class PopupListener extends MouseAdapter {
private static class PopupListener extends MouseAdapter {
JPopupMenu popup;

PopupListener(JPopupMenu popupMenu) {
popup = popupMenu;
}

@Override
public void mousePressed(MouseEvent e) {
maybeShowPopup(e);
}

@Override
public void mouseReleased(MouseEvent e) {
maybeShowPopup(e);
}
@@ -308,6 +320,7 @@ public class LiteDebugger implements SmackDebugger {
}
}

@Override
public Reader newConnectionReader(Reader newReader) {
((ObservableReader)reader).removeReaderListener(readerListener);
ObservableReader debugReader = new ObservableReader(newReader);
@@ -316,6 +329,7 @@ public class LiteDebugger implements SmackDebugger {
return reader;
}

@Override
public Writer newConnectionWriter(Writer newWriter) {
((ObservableWriter)writer).removeWriterListener(writerListener);
ObservableWriter debugWriter = new ObservableWriter(newWriter);
@@ -332,18 +346,22 @@ public class LiteDebugger implements SmackDebugger {
frame.setTitle(title);
}

@Override
public Reader getReader() {
return reader;
}

@Override
public Writer getWriter() {
return writer;
}

@Override
public StanzaListener getReaderListener() {
return listener;
}

@Override
public StanzaListener getWriterListener() {
return null;
}


+ 2
- 0
smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java View File

@@ -72,6 +72,7 @@ public final class CarbonManager extends Manager {

static {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
@Override
public void connectionCreated(XMPPConnection connection) {
getInstanceFor(connection);
}
@@ -271,6 +272,7 @@ public final class CarbonManager extends Manager {

try {
connection().sendIqWithResponseCallback(setIQ, new StanzaListener() {
@Override
public void processStanza(Stanza packet) {
enabled_state = use;
}


+ 1
- 0
smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/packet/AbstractHttpOverXmpp.java View File

@@ -44,6 +44,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
this.version = Objects.requireNonNull(builder.version, "version must not be null");
}

@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
IQChildElementXmlStringBuilder builder = getIQHoxtChildElementBuilder(xml);
builder.optAppend(headers);


+ 17
- 2
smack-experimental/src/main/java/org/jivesoftware/smackx/iot/control/element/IoTSetRequest.java View File

@@ -1,6 +1,6 @@
/**
*
* Copyright © 2016 Florian Schmaus
* Copyright © 2016-2017 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
*/
package org.jivesoftware.smackx.iot.control.element;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

@@ -31,7 +32,21 @@ public class IoTSetRequest extends IQ {
public IoTSetRequest(Collection<? extends SetData> setData) {
super(ELEMENT, NAMESPACE);
setType(Type.set);
this.setData = Collections.unmodifiableCollection(setData);

/*
* Ugly workaround for the following error prone false positive:
*
* IoTSetRequest.java:34: error: incompatible types: Collection<CAP#1> cannot be converted to Collection<SetData>
* this.setData = Collections.unmodifiableCollection(setDataA);
* ^
* where CAP#1 is a fresh type-variable:
* CAP#1 extends SetData from capture of ? extends SetData
*/
Collection<SetData> tmp = new ArrayList<>(setData.size());
for (SetData data : setData) {
tmp.add(data);
}
this.setData = Collections.unmodifiableCollection(tmp);
}

public Collection<SetData> getSetData() {


+ 1
- 1
smack-experimental/src/main/java/org/jivesoftware/smackx/iot/control/element/SetData.java View File

@@ -30,7 +30,7 @@ public abstract class SetData implements NamedElement {
DOUBLE,
;

private String toStringCache;
private final String toStringCache;

private Type() {
toStringCache = this.name().toLowerCase(Locale.US);


+ 1
- 0
smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/IoTDataManager.java View File

@@ -61,6 +61,7 @@ public final class IoTDataManager extends IoTManager {
// Ensure a IoTDataManager exists for every connection.
static {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
@Override
public void connectionCreated(XMPPConnection connection) {
if (!isAutoEnableActive()) return;
getInstanceFor(connection);


+ 1
- 0
smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java View File

@@ -74,6 +74,7 @@ public final class IoTDiscoveryManager extends Manager {
// Ensure a IoTProvisioningManager exists for every connection.
static {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
@Override
public void connectionCreated(XMPPConnection connection) {
if (!IoTManager.isAutoEnableActive()) return;
getInstanceFor(connection);


+ 1
- 0
smack-experimental/src/main/java/org/jivesoftware/smackx/iot/element/NodeInfo.java View File

@@ -62,6 +62,7 @@ public final class NodeInfo {
}

@Override
@SuppressWarnings("ReferenceEquality")
public int hashCode() {
if (this == EMPTY) {
return 0;


+ 1
- 0
smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java View File

@@ -82,6 +82,7 @@ public final class IoTProvisioningManager extends Manager {
// Ensure a IoTProvisioningManager exists for every connection.
static {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
@Override
public void connectionCreated(XMPPConnection connection) {
if (!IoTManager.isAutoEnableActive()) return;
getInstanceFor(connection);


+ 66
- 3
smack-extensions/src/main/java/org/jivesoftware/smack/chat2/ChatManager.java View File

@@ -53,6 +53,7 @@ import org.jxmpp.jid.Jid;
*
* @see <a href="https://xmpp.org/extensions/xep-0296.html">XEP-0296: Best Practices for Resource Locking</a>
*/
@SuppressWarnings("FunctionalInterfaceClash")
public final class ChatManager extends Manager {

private static final Map<XMPPConnection, ChatManager> INSTANCES = new WeakHashMap<>();
@@ -188,22 +189,84 @@ public final class ChatManager extends Manager {
return true;
}

public boolean addListener(IncomingChatMessageListener listener) {
/**
* Add a new listener for incoming chat messages.
*
* @param listener the listener to add.