From ac9641f09187ae4a393c5f1acb1e94e66f24a64f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 16 Feb 2019 10:00:11 +0100 Subject: [PATCH 1/4] Do not set com.sun.jndi.dns.DnsContextFactory in JavaxResolver as this is not accessible in newer Java versions (at least 11). Fixes SMACK-856. --- .../jivesoftware/smack/util/dns/javax/JavaxResolver.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/smack-resolver-javax/src/main/java/org/jivesoftware/smack/util/dns/javax/JavaxResolver.java b/smack-resolver-javax/src/main/java/org/jivesoftware/smack/util/dns/javax/JavaxResolver.java index 12cc680fe..e91802e04 100644 --- a/smack-resolver-javax/src/main/java/org/jivesoftware/smack/util/dns/javax/JavaxResolver.java +++ b/smack-resolver-javax/src/main/java/org/jivesoftware/smack/util/dns/javax/JavaxResolver.java @@ -1,6 +1,6 @@ /** * - * Copyright 2013-2018 Florian Schmaus + * Copyright 2013-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. @@ -18,7 +18,6 @@ package org.jivesoftware.smack.util.dns.javax; import java.net.InetAddress; import java.util.ArrayList; -import java.util.Hashtable; import java.util.List; import java.util.logging.Level; @@ -52,9 +51,7 @@ public class JavaxResolver extends DNSResolver implements SmackInitializer { static { try { - Hashtable env = new Hashtable<>(); - env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory"); - dirContext = new InitialDirContext(env); + dirContext = new InitialDirContext(); } catch (Exception e) { // Ignore. } From eccaf58df1d95460b05de6c35e19b70dd498c189 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 16 Feb 2019 10:03:05 +0100 Subject: [PATCH 2/4] Add Logger to JavaxResolver --- .../org/jivesoftware/smack/util/dns/javax/JavaxResolver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smack-resolver-javax/src/main/java/org/jivesoftware/smack/util/dns/javax/JavaxResolver.java b/smack-resolver-javax/src/main/java/org/jivesoftware/smack/util/dns/javax/JavaxResolver.java index e91802e04..0d4825bfa 100644 --- a/smack-resolver-javax/src/main/java/org/jivesoftware/smack/util/dns/javax/JavaxResolver.java +++ b/smack-resolver-javax/src/main/java/org/jivesoftware/smack/util/dns/javax/JavaxResolver.java @@ -53,7 +53,7 @@ public class JavaxResolver extends DNSResolver implements SmackInitializer { try { dirContext = new InitialDirContext(); } catch (Exception e) { - // Ignore. + LOGGER.log(Level.SEVERE, "Could not construct InitialDirContext", e); } // Try to set this DNS resolver as primary one From db8e37d75f374fad17c74ab9a45036a67dfd8b92 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 16 Feb 2019 10:03:32 +0100 Subject: [PATCH 3/4] Reduce scope of catched Exceptions in JavaxResolver --- .../org/jivesoftware/smack/util/dns/javax/JavaxResolver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smack-resolver-javax/src/main/java/org/jivesoftware/smack/util/dns/javax/JavaxResolver.java b/smack-resolver-javax/src/main/java/org/jivesoftware/smack/util/dns/javax/JavaxResolver.java index 0d4825bfa..e83c588f6 100644 --- a/smack-resolver-javax/src/main/java/org/jivesoftware/smack/util/dns/javax/JavaxResolver.java +++ b/smack-resolver-javax/src/main/java/org/jivesoftware/smack/util/dns/javax/JavaxResolver.java @@ -52,7 +52,7 @@ public class JavaxResolver extends DNSResolver implements SmackInitializer { static { try { dirContext = new InitialDirContext(); - } catch (Exception e) { + } catch (NamingException e) { LOGGER.log(Level.SEVERE, "Could not construct InitialDirContext", e); } From e9b514548b54affed48522a2d61248bf7aee53e1 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 17 Feb 2019 21:54:38 +0100 Subject: [PATCH 4/4] Filter error messages in DeliveryReceiptManager --- .../smackx/receipts/DeliveryReceiptManager.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java index dbfd61436..c310ceb25 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java @@ -1,6 +1,6 @@ /** * - * Copyright 2013-2014 Georg Lukas, 2015 Florian Schmaus + * Copyright 2013-2014 Georg Lukas, 2015-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. @@ -74,8 +74,16 @@ import org.jxmpp.jid.Jid; */ public final class DeliveryReceiptManager extends Manager { - private static final StanzaFilter MESSAGES_WITH_DELIVERY_RECEIPT_REQUEST = new AndFilter(StanzaTypeFilter.MESSAGE, - new StanzaExtensionFilter(new DeliveryReceiptRequest())); + /** + * Filters all non-error messages with receipt requests. + * See XEP-0184 § 5. "A sender could request receipts + * on any non-error content message (chat, groupchat, headline, or normal)…" + */ + private static final StanzaFilter NON_ERROR_GROUPCHAT_MESSAGES_WITH_DELIVERY_RECEIPT_REQUEST = new AndFilter( + StanzaTypeFilter.MESSAGE, + new StanzaExtensionFilter(new DeliveryReceiptRequest()), + new NotFilter(MessageTypeFilter.ERROR)); + private static final StanzaFilter MESSAGES_WITH_DELIVERY_RECEIPT = new AndFilter(StanzaTypeFilter.MESSAGE, new StanzaExtensionFilter(DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE)); @@ -175,7 +183,7 @@ public final class DeliveryReceiptManager extends Manager { } connection.sendStanza(ack); } - }, MESSAGES_WITH_DELIVERY_RECEIPT_REQUEST); + }, NON_ERROR_GROUPCHAT_MESSAGES_WITH_DELIVERY_RECEIPT_REQUEST); } /**