@Test public void testOnOkThread() { Thread thread = factory.newThread(new Runnable() { @Override public void run() { } }); thread.run(); assertThat(log.error).isNull(); }
@Override public Thread newThread(final Runnable runnable) { Runnable wrapped = new Runnable() { @Override public void run() { try { runnable.run(); } catch (Exception e) { log.error("Error while executing " + Thread.currentThread().getName(), e); } } }; Thread thread = factory.newThread(wrapped); thread.setName(prefix + "-" + thread.getName()); return thread; }
DefensiveThreadFactory implements ThreadFactory { @Override public Thread newThread(final Runnable runnable) { Runnable wrapped = new Runnable() { @Override public void run() { try { runnable.run(); } catch (Exception e) { log.error("Error while executing " + Thread.currentThread().getName(), e); } } }; Thread thread = factory.newThread(wrapped); thread.setName(prefix + "-" + thread.getName()); return thread; } }
DefensiveThreadFactory implements ThreadFactory { @Override public Thread newThread(final Runnable runnable) { Runnable wrapped = new Runnable() { @Override public void run() { try { runnable.run(); } catch (Exception e) { log.error("Error while executing " + Thread.currentThread().getName(), e); } } }; Thread thread = factory.newThread(wrapped); thread.setName(prefix + "-" + thread.getName()); return thread; } DefensiveThreadFactory(String name, Mojo mojo); }
DefensiveThreadFactory implements ThreadFactory { @Override public Thread newThread(final Runnable runnable) { Runnable wrapped = new Runnable() { @Override public void run() { try { runnable.run(); } catch (Exception e) { log.error("Error while executing " + Thread.currentThread().getName(), e); } } }; Thread thread = factory.newThread(wrapped); thread.setName(prefix + "-" + thread.getName()); return thread; } DefensiveThreadFactory(String name, Mojo mojo); @Override Thread newThread(final Runnable runnable); }
DefensiveThreadFactory implements ThreadFactory { @Override public Thread newThread(final Runnable runnable) { Runnable wrapped = new Runnable() { @Override public void run() { try { runnable.run(); } catch (Exception e) { log.error("Error while executing " + Thread.currentThread().getName(), e); } } }; Thread thread = factory.newThread(wrapped); thread.setName(prefix + "-" + thread.getName()); return thread; } DefensiveThreadFactory(String name, Mojo mojo); @Override Thread newThread(final Runnable runnable);  }