@Override public void setErrorManager(ErrorManager em) { super.setErrorManager(em); Handler t = resolve(); if(t!=null) t.setErrorManager(em); }
@Test public void testReportFormatError() { expect(options.getProjectId()).andReturn(PROJECT).anyTimes(); expect(options.getService()).andReturn(logging); logging.setFlushSeverity(Severity.ERROR); expectLastCall().once(); logging.setWriteSynchronicity(Synchronicity.ASYNC); expectLastCall().once(); replay(options, logging); Formatter formatter = EasyMock.createStrictMock(Formatter.class); RuntimeException ex = new RuntimeException(); ErrorManager errorManager = EasyMock.createStrictMock(ErrorManager.class); errorManager.error(null, ex, ErrorManager.FORMAT_FAILURE); expectLastCall().once(); LogRecord record = newLogRecord(Level.FINEST, MESSAGE); expect(formatter.format(record)).andThrow(ex); replay(errorManager, formatter); Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE); handler.setLevel(Level.ALL); handler.setErrorManager(errorManager); handler.setFormatter(formatter); handler.publish(record); verify(errorManager, formatter); }
@Test public void testReportWriteError() { expect(options.getProjectId()).andReturn(PROJECT).anyTimes(); expect(options.getService()).andReturn(logging); RuntimeException ex = new RuntimeException(); logging.setFlushSeverity(Severity.ERROR); expectLastCall().once(); logging.setWriteSynchronicity(Synchronicity.ASYNC); expectLastCall().once(); logging.write(ImmutableList.of(FINEST_ENTRY), DEFAULT_OPTIONS); expectLastCall().andStubThrow(ex); replay(options, logging); ErrorManager errorManager = EasyMock.createStrictMock(ErrorManager.class); errorManager.error(null, ex, ErrorManager.WRITE_FAILURE); expectLastCall().once(); replay(errorManager); Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE); handler.setLevel(Level.ALL); handler.setErrorManager(errorManager); handler.setFormatter(new TestFormatter()); handler.publish(newLogRecord(Level.FINEST, MESSAGE)); verify(errorManager); }
/** * Sets the error manager on this handler and the super handler. In secure * environments the super call may not be allowed which is not a failure * condition as it is an attempt to free the unused handler error manager. * * @param em a non null error manager. * @throws NullPointerException if the given error manager is null. * @since JavaMail 1.5.6 */ private void setErrorManager0(final ErrorManager em) { if (em == null) { throw new NullPointerException(); } try { synchronized (this) { //Wait for writeLogRecords. this.errorManager = em; super.setErrorManager(em); //Try to free super error manager. } } catch (RuntimeException | LinkageError ignore) { } }
/** * Sets the error manager on this handler and the super handler. In secure * environments the super call may not be allowed which is not a failure * condition as it is an attempt to free the unused handler error manager. * * @param em a non null error manager. * @throws NullPointerException if the given error manager is null. * @since JavaMail 1.5.6 */ private void setErrorManager0(final ErrorManager em) { if (em == null) { throw new NullPointerException(); } try { synchronized (this) { //Wait for writeLogRecords. this.errorManager = em; super.setErrorManager(em); //Try to free super error manager. } } catch (final RuntimeException ignore) { } catch (final LinkageError ignore) { } }
@Test public void testReportFlushError() { expect(options.getProjectId()).andReturn(PROJECT).anyTimes(); expect(options.getService()).andReturn(logging); RuntimeException ex = new RuntimeException(); logging.setFlushSeverity(Severity.ERROR); expectLastCall().once(); logging.setWriteSynchronicity(Synchronicity.ASYNC); expectLastCall().once(); logging.write(ImmutableList.of(FINEST_ENTRY), DEFAULT_OPTIONS); expectLastCall().once(); logging.flush(); expectLastCall().andThrow(ex); ErrorManager errorManager = EasyMock.createStrictMock(ErrorManager.class); errorManager.error(null, ex, ErrorManager.FLUSH_FAILURE); expectLastCall().once(); replay(options, logging, errorManager); LogRecord record = newLogRecord(Level.FINEST, MESSAGE); Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE); handler.setLevel(Level.ALL); handler.setErrorManager(errorManager); handler.setFormatter(new TestFormatter()); handler.publish(record); handler.flush(); verify(errorManager); }
/** * {@inheritDoc} */ public void setErrorManager(ErrorManager em) { handler.setErrorManager(em); }
/** * {@inheritDoc} */ public void setErrorManager(ErrorManager em) { handler.setErrorManager(em); }
/** * {@inheritDoc} */ public void setErrorManager(ErrorManager em) { handler.setErrorManager(em); }
@Override public void setErrorManager(ErrorManager em) { super.setErrorManager(em); Handler t = resolve(); if(t!=null) t.setErrorManager(em); }
@Override public void setErrorManager(ErrorManager em) { super.setErrorManager(em); Handler t = resolve(); if (t != null) { t.setErrorManager(em); } }
@Override public void setErrorManager(ErrorManager em) { super.setErrorManager(em); Handler t = resolve(); if(t!=null) t.setErrorManager(em); }
@Override public void setErrorManager(ErrorManager em) { super.setErrorManager(em); Handler t = resolve(); if(t!=null) t.setErrorManager(em); }
@Override public void setErrorManager(ErrorManager em) { super.setErrorManager(em); Handler t = resolve(); if(t!=null) t.setErrorManager(em); }
/** * Used internally to parse an {@link ErrorManager} element. */ protected void parseErrorManager(Element element, Handler appender) throws Exception { String className = subst(element.getAttribute(CLASS_ATTR)); ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class ehClazz = loader.loadClass(className); ErrorManager eh = (ErrorManager) ehClazz.newInstance(); appender.setErrorManager(eh); }
@Override public void setErrorManager(final ErrorManager em) { checkAccess(this); super.setErrorManager(em); }
/** * Used internally to parse an {@link ErrorManager} element. */ protected void parseErrorManager(Element element, Handler appender) throws Exception { String className = subst(element.getAttribute(CLASS_ATTR)); ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class ehClazz = loader.loadClass(className); ErrorManager eh = (ErrorManager) ehClazz.newInstance(); appender.setErrorManager(eh); }
/** * Construct a new instance. */ protected ExtHandler() { handlersUpdater.clear(this); closeChildren = true; super.setErrorManager(DEFAULT_ERROR_MANAGER); }
@Override public void setErrorManager(@Nullable ErrorManager errorManager) { if (this.delegate != null) this.delegate.setErrorManager(errorManager); }
private void initErrorManager(LogManager manager, String p) { assert Thread.holdsLock(this); String name = manager.getProperty(p.concat(".errorManager")); if (name != null) { try { ErrorManager em = LogManagerProperties.newErrorManager(name); super.setErrorManager(em); } catch (final SecurityException SE) { throw SE; //Avoid catch all. } catch (final Exception E) { reportError(E.getMessage(), E, ErrorManager.OPEN_FAILURE); } } }