java.util.concurrent.RejectedExecutionException experienced when loading the roster using Smack API

After upgrading to Smack 4.1.4 we are experiencing the exception

We have 3,451 users in openfire, which has not been an issue previously. The following code is being used to replicate the issue:

    final XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder();

    builder.setServiceName("HOSTNAME");

    final XMPPTCPConnectionConfiguration config = builder.build();

    final XMPPTCPConnection connection = new XMPPTCPConnection(config);

    connection.connect();

    System.out.println("connection.isConnected() = " + connection.isConnected());

    connection.login("USERNAME", "PASSWORD", null);

    System.out.println("connection.isAuthenticated() = " + connection.isAuthenticated());

    System.out.println("Initiating roster load");

    final Roster roster = Roster.getInstanceFor(connection);

    System.out.println("Returned from initiating roster load");

   

    final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    while(true){

        final String input = reader.readLine();

        if(input!=null){

            break;

        }

    }

    connection.disconnect();

Output from the program :

Nov 19, 2015 12:59:32 PM org.jivesoftware.smack.util.DNSUtil resolveXMPPDomain

WARNING: No DNS Resolver active in Smack, will be unable to perform DNS SRV lookups

connection.isConnected() = true

connection.isAuthenticated() = true

Initiating roster load

Returned from initiating roster load

Nov 19, 2015 12:59:34 PM org.jivesoftware.smack.AbstractXMPPConnection callConnectionClosedOnErrorListener

WARNING: Connection closed with error

java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@3b19079e rejected from java.util.concurrent.ThreadPoolExecutor@142401c1[Running, pool size = 1, active threads = 1, queued tasks = 97, completed tasks = 265]

at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoo lExecutor.java:2048)

at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:821)

at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1372)

at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.jav a:110)

at org.jivesoftware.smack.AbstractXMPPConnection.processPacket(AbstractXMPPConnect ion.java:984)

at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMP PConnection.java:969)

at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$500(XMPPTCPConnection.java: 140)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:989)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPCon nection.java:944)

at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:959)

at java.lang.Thread.run(Thread.java:744)

Despite the above error if I add a org.jivesoftware.smack.roster.RosterListener to the roster I can see that we receive 3447 entries added. I’m not sure where the missing 4 go from the 3451 users in openfire, but I am cannot say whether that is significant to this issue or not.

I have enabled the smack.debugEnabled system property, but fail to see any other errors that would help me diagnose this issue.

Has anyone else experienced this issue and come across a solution? Is this a not entirely unexpected error that I should be catching/logging/ignoring?

Thanks,

Sam Clunie

Thanks for reporting. That appears to be a bug in Smack. I assume the Executor has no, or the wrong, rejection policy set. Will have a look and report back.

Thanks Flow. Appreciate it.

Created SMACK-702, tracked as [SMACK-702] RejectedExecutionException in AbstractXMPPConnection.processPacket() causes connection Termination - Jive So…

I’ve uploaded Smack 4.1.5-SNAPSHOT with a supposed fix for the issue. Could you try and report back if works? Snapshot versions are available from the Maven Central snapshot repository.

Thanks Flow!

I’ve given my original code a run through multiple times switching between 4.1.4 and 4.1.5-SNAPSHOT libs, and can reliably replicate with 4.1.4, but not once with 4.1.5-SNAPSHOT.

I’d say it’s looking pretty good

Hi Flow,

I see that SMACK-702 has been marked as resolved. Do you have an ETA on the 4.1.5 release? If not, I’ll likely downgrade to 4.0.7 for our upcoming product release.

Thanks.

Smack 4.1.5 is already available on Maven Central. The website update and blog post announcing the release are pending. I’ll likely do that today (or pretty soon™).

Perfect, thanks Flow. Appreciate the quick response.