MailHandler extends Handler { private void initAttachmentNames(LogManager manager, String p) { assert Thread.holdsLock(this); assert this.attachmentFormatters != null; final String list = manager.getProperty(p.concat(".attachment.names")); if (!isEmpty(list)) { final String[] names = list.split(","); final Formatter[] a = new Formatter[names.length]; for (int i = 0; i < a.length; ++i) { names[i] = names[i].trim(); if (!"null".equalsIgnoreCase(names[i])) { try { try { a[i] = LogManagerProperties.newFormatter(names[i]); } catch (final ClassNotFoundException literal) { a[i] = new TailNameFormatter(names[i]); } catch (final ClassCastException literal) { a[i] = new TailNameFormatter(names[i]); } } catch (final SecurityException SE) { throw SE; } catch (final Exception E) { reportError(E.getMessage(), E, ErrorManager.OPEN_FAILURE); } } else { final Exception NPE = new NullPointerException(atIndexMsg(i)); reportError("Attachment names.", NPE, ErrorManager.OPEN_FAILURE); } } this.attachmentNames = a; if (fixUpAttachmentNames()) { reportError("Attachment names.", attachmentMismatch("Length mismatch."), ErrorManager.OPEN_FAILURE); } } else { this.attachmentNames = emptyFormatterArray(); fixUpAttachmentNames(); } } MailHandler();  MailHandler(final int capacity);  MailHandler(final Properties props); @Override boolean isLoggable(final LogRecord record); void publish(final LogRecord record); void push(); void flush(); void close(); @Override synchronized void setLevel(final Level newLevel); final synchronized Level getPushLevel(); final synchronized void setPushLevel(final Level level); final synchronized Filter getPushFilter(); final synchronized void setPushFilter(final Filter filter); final synchronized Comparator<? super LogRecord> getComparator(); final synchronized void setComparator(Comparator<? super LogRecord> c); final synchronized int getCapacity(); final synchronized Authenticator getAuthenticator(); final void setAuthenticator(final Authenticator auth); final void setAuthenticator(final char... password); final void setMailProperties(Properties props); final Properties getMailProperties(); final Filter[] getAttachmentFilters(); final void setAttachmentFilters(Filter... filters); final Formatter[] getAttachmentFormatters(); final void setAttachmentFormatters(Formatter... formatters); final Formatter[] getAttachmentNames(); final void setAttachmentNames(final String... names); final void setAttachmentNames(Formatter... formatters); final synchronized Formatter getSubject(); final void setSubject(final String subject); final void setSubject(final Formatter format);  }
@Test public void testInitAttachmentNames() throws Exception { InternalErrorManager em; MailHandler target; final String p = MailHandler.class.getName(); final LogManager manager = LogManager.getLogManager(); Properties props = createInitProperties(p); props.put(p.concat(".errorManager"), InternalErrorManager.class.getName()); props.put(p.concat(".attachment.formatters"), SimpleFormatter.class.getName()); props.put(p.concat(".attachment.names"), Properties.class.getName()); read(manager, props); try { target = new MailHandler(); try { em = internalErrorManagerFrom(target); for (int i = 0; i < em.exceptions.size(); i++) { dump(em.exceptions.get(i)); } assertTrue(em.exceptions.isEmpty()); } finally { target.close(); } props.put(p.concat(".attachment.formatters"), SimpleFormatter.class.getName()); props.put(p.concat(".attachment.names"), SimpleFormatter.class.getName().toUpperCase(Locale.US)); read(manager, props); target = new MailHandler(); try { em = internalErrorManagerFrom(target); for (int i = 0; i < em.exceptions.size(); i++) { dump(em.exceptions.get(i)); } assertTrue(em.exceptions.isEmpty()); } finally { target.close(); } props.put(p.concat(".attachment.formatters"), SimpleFormatter.class.getName()); props.put(p.concat(".attachment.names"), Properties.class.getName().toUpperCase(Locale.US)); read(manager, props); target = new MailHandler(); try { em = internalErrorManagerFrom(target); for (int i = 0; i < em.exceptions.size(); i++) { dump(em.exceptions.get(i)); } assertTrue(em.exceptions.isEmpty()); } finally { target.close(); } } finally { manager.reset(); } }