- * Technically there are typically at least two parameters required: Some kind of credentials for authentication. And - * the XMPP service domain. The credentials often consists of a username and password use for the SASL authentication. - * But there are also other authentication mechanisms, like client side certificates, which do not require a particular - * username and password. - *
- *- * There are some misconceptions about XMPP client-to-server parameters: The first is that the username used for - * authentication will be equal to the localpart of the bound XMPP address after authentication. While this is usually - * true, it is not required. Technically the username used for authentication and the resulting XMPP address are - * completely independent from each other. The second common misconception steers from the terms "XMPP host" and "XMPP - * service domain": An XMPP service host is a system which hosts one or multiple XMPP domains. The "XMPP service domain" - * will be usually the domainpart of the bound JID. This domain is used to verify the remote endpoint, typically using - * TLS. This third misconception is that the XMPP service domain is required to become the domainpart of the bound JID. - * Again, while this is very common to be true, it is not strictly required. - *
+ * Configuration to use while establishing the connection to the server. * * @author Gaston Dombiak - * @author Florian Schmaus */ public abstract class ConnectionConfiguration { @@ -554,39 +534,6 @@ public abstract class ConnectionConfiguration { } } - /** - * Convenience method to configure the username, password and XMPP service domain. - * - * @param jid the XMPP address of the user. - * @param password the password of the user. - * @return a reference to this builder. - * @throws XmppStringprepException in case the XMPP address is not valid. - * @see #setXmppAddressAndPassword(EntityBareJid, String) - * @since 4.4.0 - */ - public B setXmppAddressAndPassword(CharSequence jid, String password) throws XmppStringprepException { - return setXmppAddressAndPassword(JidCreate.entityBareFrom(jid), password); - } - - /** - * Convenience method to configure the username, password and XMPP service domain. The localpart of the provided - * JID is used as username and the domanipart is used as XMPP service domain. - *- * Please note that this does and can not configure the client XMPP address. XMPP services are not required to - * assign bound JIDs where the localpart matches the username and the domainpart matches the verified domainpart. - * Although most services will follow that pattern. - *
- * - * @param jid - * @param password - * @return a reference to this builder. - * @since 4.4.0 - */ - public B setXmppAddressAndPassword(EntityBareJid jid, String password) { - setUsernameAndPassword(jid.getLocalpart(), password); - return setXmppDomain(jid.asDomainBareJid()); - } - /** * Set the XMPP entities username and password. *diff --git a/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java b/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java index 10695df47..01f2995a4 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java @@ -365,19 +365,4 @@ public final class SmackConfiguration { public static void setUnknownIqRequestReplyMode(UnknownIqRequestReplyMode unknownIqRequestReplyMode) { SmackConfiguration.unknownIqRequestReplyMode = Objects.requireNonNull(unknownIqRequestReplyMode, "Must set mode"); } - - private static final int defaultConcurrencyLevelLimit; - - static { - int availableProcessors = Runtime.getRuntime().availableProcessors(); - if (availableProcessors < 8) { - defaultConcurrencyLevelLimit = 8; - } else { - defaultConcurrencyLevelLimit = (int) (availableProcessors * 1.1); - } - } - - public static int getDefaultConcurrencyLevelLimit() { - return defaultConcurrencyLevelLimit; - } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java index cd7c6cf7e..c6c2db78f 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java @@ -70,27 +70,6 @@ import org.jxmpp.jid.EntityFullJid; * disconnected and then connected again. Listeners of the XMPPConnection will be retained across * connections. *
- *- * Standard callbacks are invoked concurrently, but it is ensured that the same callback is never run concurrently. - * The callback's identity is used as key for that. The events delivered to the callback preserve the order of the - * causing events of the connection. - *
- *- * Asynchronous callbacks are run decoupled from the connections main event loop. Hence a callback triggered by - * stanza B may (appear to) invoked before a callback triggered by stanza A, even though stanza A arrived before B. - *
- *- * Synchronous callbacks are run synchronous to the main event loop of a connection. Hence they are invoked in the - * exact order of how events happen there, most importantly the arrival order of incoming stanzas. You should only - * use synchronous callbacks in rare situations. - *
* * @author Matt Tucker * @author Guenther Niess diff --git a/smack-core/src/main/java/org/jivesoftware/smack/debugger/ConsoleDebugger.java b/smack-core/src/main/java/org/jivesoftware/smack/debugger/ConsoleDebugger.java index def9b310e..fb5d80a69 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/debugger/ConsoleDebugger.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/debugger/ConsoleDebugger.java @@ -16,11 +16,12 @@ */ package org.jivesoftware.smack.debugger; +import java.io.PrintWriter; +import java.io.StringWriter; import java.text.SimpleDateFormat; import java.util.Date; import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.util.ExceptionUtil; /** * Very simple debugger that prints to the console (stdout) the sent and received stanzas. Use @@ -54,8 +55,12 @@ public class ConsoleDebugger extends AbstractDebugger { @Override protected void log(String logMessage, Throwable throwable) { - String stacktrace = ExceptionUtil.getStackTrace(throwable); - log(logMessage + '\n' + stacktrace); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + // CHECKSTYLE:OFF + throwable.printStackTrace(pw); + // CHECKSTYLE:ON + log(logMessage + sw); } public static final class Factory implements SmackDebuggerFactory { diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/AbstractError.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/AbstractError.java index e75e7a0e9..ece30af7b 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/AbstractError.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/AbstractError.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import org.jivesoftware.smack.util.ExceptionUtil; import org.jivesoftware.smack.util.Objects; import org.jivesoftware.smack.util.PacketUtil; import org.jivesoftware.smack.util.XmlStringBuilder; @@ -151,17 +150,6 @@ public class AbstractError { return getThis(); } - public B setDescriptiveEnText(String descriptiveEnText, Exception exception) { - StringBuilder sb = new StringBuilder(512); - sb.append(descriptiveEnText) - .append('\n'); - - String stacktrace = ExceptionUtil.getStackTrace(exception); - sb.append(stacktrace); - - return setDescriptiveEnText(sb.toString()); - } - public B setTextNamespace(String textNamespace) { this.textNamespace = textNamespace; return getThis(); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java index 9b15c9c95..3626b9b9b 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java @@ -105,16 +105,6 @@ public abstract class IQ extends Stanza { } } - /** - * Return true if this IQ is a request, i.e. an IQ of type {@link Type#result} or {@link Type#error}. - * - * @return true if IQ type is 'result' or 'error', false otherwise. - * @since 4.4 - */ - public boolean isResponseIQ() { - return !isRequestIQ(); - } - public final String getChildElementName() { return childElementName; } @@ -297,7 +287,7 @@ public abstract class IQ extends Stanza { * @return a new {@link Type#error IQ.Type.error} IQ based on the originating IQ. */ public static ErrorIQ createErrorResponse(final IQ request, final StanzaError.Builder error) { - if (!request.isRequestIQ()) { + if (!(request.getType() == Type.get || request.getType() == Type.set)) { throw new IllegalArgumentException( "IQ must be of type 'set' or 'get'. Original IQ: " + request.toXML()); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/ExceptionUtil.java b/smack-core/src/main/java/org/jivesoftware/smack/util/ExceptionUtil.java deleted file mode 100644 index 1c282381a..000000000 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/ExceptionUtil.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * - * Copyright 2019 Florian Schmaus. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jivesoftware.smack.util; - -import java.io.PrintWriter; -import java.io.StringWriter; - -public class ExceptionUtil { - - public static String getStackTrace(Throwable throwable) { - StringWriter stringWriter = new StringWriter(); - PrintWriter printWriter = new PrintWriter(stringWriter); - - // CHECKSTYLE:OFF - throwable.printStackTrace(printWriter); - // CHECKSTYLE:ON - - printWriter.flush(); - - StringBuffer stringBuffer = stringWriter.getBuffer(); - return stringBuffer.toString(); - } - -} diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/RandomUtil.java b/smack-core/src/main/java/org/jivesoftware/smack/util/RandomUtil.java deleted file mode 100644 index 857557869..000000000 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/RandomUtil.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * - * Copyright 2003-2007 Jive Software, 2016-2019 Florian Schmaus. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jivesoftware.smack.util; - -import java.security.SecureRandom; -import java.util.Random; - -public class RandomUtil { - - static final ThreadLocal- * Note that this test is based on the assumption that it is possible to trigger a full garbage collection run, which is - * not the case. See also this - * stackoverflow - * question. Hence the {@link #triggerGarbageCollection()} method defined in this class is not portable and depends - * on implementation depended Java Virtual Machine behavior. - *
- * - * @see SMACK-383 Jira Issue - */ -public class MemoryLeakTestUtil { - - private static final Logger LOGGER = Logger.getLogger(MemoryLeakTestUtil.class.getName()); - - public static