Skip to content

Commit

Permalink
MailHander should catch ServiceConfigurationError eclipse-ee4j#123
Browse files Browse the repository at this point in the history
Signed-off-by: jmehrens <[email protected]>
  • Loading branch information
jmehrens committed Feb 1, 2024
1 parent f2b62ed commit b266073
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
Expand Down Expand Up @@ -56,7 +57,9 @@ abstract class AbstractLogging {
*/
@SuppressWarnings({"CallToThreadDumpStack", "CallToPrintStackTrace"})
static void dump(final Throwable t) {
t.printStackTrace();
PrintStream err = System.err;
err.print(AbstractLogging.class.getSimpleName() + ": ");
t.printStackTrace(err);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,16 @@ private void testCallingClassLoader(boolean secure, ClassLoader expect) {
((ClassLoaderThread) clt).secure = false;
}

assert em != null;
boolean fail = false;
for (Exception exception : em.exceptions) {
Throwable t = exception;
if (t instanceof MessagingException == false) {
dump(t);
fail(t.toString());
fail = true;
}
}
assertFalse(em.exceptions.isEmpty());
assertFalse(fail);
}

@Test
Expand Down Expand Up @@ -413,14 +414,16 @@ private void testVerify(boolean secure, ClassLoader expect) throws Exception {
manager.reset();
}

assert em != null;
boolean fail = false;
for (Exception exception : em.exceptions) {
Throwable t = exception;
if (t instanceof MessagingException == false) {
dump(t);
fail = true;
}
}
assertFalse(em.exceptions.isEmpty());
assertFalse(fail);
}

@Test
Expand Down Expand Up @@ -477,14 +480,16 @@ private void testSetMailProperties(boolean secure, ClassLoader expect) throws Ex
((ClassLoaderThread) clt).secure = false;
}

assert em != null;
boolean fail = false;
for (Exception exception : em.exceptions) {
Throwable t = exception;
if (t instanceof MessagingException == false) {
dump(t);
fail = true;
}
}
assertFalse(em.exceptions.isEmpty());
assertFalse(fail);
}

@Test
Expand Down

0 comments on commit b266073

Please sign in to comment.