From 525feaa16156da1197338877e15d3a0ab54ec8ab Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 12 Mar 2017 14:55:38 +0100 Subject: [PATCH] Add SynchronizationPoint.getFailureException() --- .../org/jivesoftware/smack/SynchronizationPoint.java | 10 ++++++++++ .../smack/WaitForClosingStreamElementTest.java | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/SynchronizationPoint.java b/smack-core/src/main/java/org/jivesoftware/smack/SynchronizationPoint.java index 2fa69d72f..bb1984a1f 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/SynchronizationPoint.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/SynchronizationPoint.java @@ -226,6 +226,16 @@ public class SynchronizationPoint { } } + public E getFailureException() { + connectionLock.lock(); + try { + return failureException; + } + finally { + connectionLock.unlock(); + } + } + /** * Wait for the condition to become something else as {@link State#RequestSent} or {@link State#Initial}. * {@link #reportSuccess()}, {@link #reportFailure()} and {@link #reportFailure(Exception)} will either set this diff --git a/smack-integration-test/src/main/java/org/jivesoftware/smack/WaitForClosingStreamElementTest.java b/smack-integration-test/src/main/java/org/jivesoftware/smack/WaitForClosingStreamElementTest.java index d4cb640e3..442bdbece 100644 --- a/smack-integration-test/src/main/java/org/jivesoftware/smack/WaitForClosingStreamElementTest.java +++ b/smack-integration-test/src/main/java/org/jivesoftware/smack/WaitForClosingStreamElementTest.java @@ -1,6 +1,6 @@ /** * - * Copyright 2015 Florian Schmaus + * Copyright 2015-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. @@ -40,6 +40,10 @@ public class WaitForClosingStreamElementTest extends AbstractSmackLowLevelIntegr Field closingStreamReceivedField = connection.getClass().getDeclaredField("closingStreamReceived"); closingStreamReceivedField.setAccessible(true); SynchronizationPoint closingStreamReceived = (SynchronizationPoint) closingStreamReceivedField.get(connection); + Exception failureException = closingStreamReceived.getFailureException(); + if (failureException != null) { + throw new AssertionError("Sync poing yielded failure exception", failureException); + } assertTrue(closingStreamReceived.wasSuccessful()); } }