@Test public void testIntern() throws Exception { final String p = MailHandler.class.getName(); Properties props = createInitProperties(p); props.put(p.concat(".errorManager"), InternFilterErrorManager.class.getName()); props.put(p.concat(".comparator"), InternFilterFormatterComparator.class.getName()); props.put(p.concat(".filter"), InternFilter.class.getName()); props.put(p.concat(".pushFilter"), InternFilterErrorManager.class.getName()); props.put(p.concat(".attachment.formatters"), SimpleFormatter.class.getName() + ", " + InternFilterFormatter.class.getName() + ", " + InternFormatter.class.getName() + ", " + XMLFormatter.class.getName() + ", " + InternFormatter.class.getName() + ", " + SimpleFormatter.class.getName() + ", " + SimpleFormatter.class.getName()); props.put(p.concat(".attachment.filters"), null + ", " + InternFilterFormatter.class.getName() + ", " + InternFilterFormatter.class.getName() + ", " + InternFilter.class.getName() + ", " + InternFilter.class.getName() + ", " + InternBadSubFilter.class.getName() + ", " + InternBadFilter.class.getName()); final String txt = "Intern test"; props.put(p.concat(".attachment.names"), txt + ", " + InternFilterFormatter.class.getName() + ", " + InternFilterFormatter.class.getName() + ", " + txt + ", " + InternFormatter.class.getName() + ", " + InternFilterFormatterComparator.class.getName() + ", " + InternFilterFormatterComparator.class.getName()); props.put(p.concat(".subject"), txt); MailHandler instance = testIntern(p, props); instance.close(); Formatter[] formatter = instance.getAttachmentFormatters(); Filter[] filter = instance.getAttachmentFilters(); Formatter[] names = instance.getAttachmentNames(); assertSame(instance.getErrorManager(), instance.getPushFilter()); assertNull(filter[0]); assertSame(filter[1], filter[2]); assertSame(filter[1], formatter[1]); assertSame(filter[2], formatter[1]); assertSame(names[1], filter[1]); assertSame(names[1], formatter[1]); assertSame(names[2], filter[2]); assertSame(names[2], formatter[1]); assertSame(names[1], filter[2]); assertNotNull(instance.getSubject()); assertSame(instance.getSubject(), names[0]); assertSame(instance.getSubject(), names[3]); assertSame(names[0], names[3]); assertNotNull(instance.getFilter()); assertSame(instance.getFilter(), filter[3]); assertSame(instance.getFilter(), filter[4]); assertSame(filter[3], filter[4]); assertNotSame(filter[5], filter[6]); assertNotNull(instance.getComparator()); assertNotSame(instance.getComparator(), names[5]); assertNotSame(instance.getComparator(), names[6]); assertSame(names[5], names[6]); InternalErrorManager em = internalErrorManagerFrom(instance); for (int i = 0; i < em.exceptions.size(); i++) { final Throwable t = em.exceptions.get(i); if (t instanceof IllegalArgumentException && String.valueOf(t.getMessage()).contains("equal")) { continue; } dump(t); } assertFalse(em.exceptions.isEmpty()); }
private void intern() { assert Thread.holdsLock(this); try { Object canidate; Object result; final Map<Object, Object> seen = new HashMap<Object, Object>(); try { intern(seen, super.getErrorManager()); } catch (final SecurityException se) { reportError(se.getMessage(), se, ErrorManager.OPEN_FAILURE); } try { canidate = super.getFilter(); result = intern(seen, canidate); if (result != canidate) { super.setFilter(Filter.class.cast(result)); } canidate = super.getFormatter(); result = intern(seen, canidate); if (result != canidate) { super.setFormatter(Formatter.class.cast(result)); } } catch (final SecurityException se) { reportError(se.getMessage(), se, ErrorManager.OPEN_FAILURE); } canidate = this.subjectFormatter; result = intern(seen, canidate); if (result != canidate) { this.subjectFormatter = Formatter.class.cast(result); } canidate = this.pushFilter; result = intern(seen, canidate); if (result != canidate) { this.pushFilter = Filter.class.cast(result); } for (int i = 0; i < attachmentFormatters.length; ++i) { canidate = attachmentFormatters[i]; result = intern(seen, canidate); if (result != canidate) { attachmentFormatters[i] = Formatter.class.cast(result); } canidate = attachmentFilters[i]; result = intern(seen, canidate); if (result != canidate) { attachmentFilters[i] = Filter.class.cast(result); } canidate = attachmentNames[i]; result = intern(seen, canidate); if (result != canidate) { attachmentNames[i] = Formatter.class.cast(result); } } } catch (final Exception skip) { reportError(skip.getMessage(), skip, ErrorManager.OPEN_FAILURE); } }
MailHandler extends Handler { private void intern() { assert Thread.holdsLock(this); try { Object canidate; Object result; final Map<Object, Object> seen = new HashMap<Object, Object>(); try { intern(seen, super.getErrorManager()); } catch (final SecurityException se) { reportError(se.getMessage(), se, ErrorManager.OPEN_FAILURE); } try { canidate = super.getFilter(); result = intern(seen, canidate); if (result != canidate) { super.setFilter(Filter.class.cast(result)); } canidate = super.getFormatter(); result = intern(seen, canidate); if (result != canidate) { super.setFormatter(Formatter.class.cast(result)); } } catch (final SecurityException se) { reportError(se.getMessage(), se, ErrorManager.OPEN_FAILURE); } canidate = this.subjectFormatter; result = intern(seen, canidate); if (result != canidate) { this.subjectFormatter = Formatter.class.cast(result); } canidate = this.pushFilter; result = intern(seen, canidate); if (result != canidate) { this.pushFilter = Filter.class.cast(result); } for (int i = 0; i < attachmentFormatters.length; ++i) { canidate = attachmentFormatters[i]; result = intern(seen, canidate); if (result != canidate) { attachmentFormatters[i] = Formatter.class.cast(result); } canidate = attachmentFilters[i]; result = intern(seen, canidate); if (result != canidate) { attachmentFilters[i] = Filter.class.cast(result); } canidate = attachmentNames[i]; result = intern(seen, canidate); if (result != canidate) { attachmentNames[i] = Formatter.class.cast(result); } } } catch (final Exception skip) { reportError(skip.getMessage(), skip, ErrorManager.OPEN_FAILURE); } } }
MailHandler extends Handler { private void intern() { assert Thread.holdsLock(this); try { Object canidate; Object result; final Map<Object, Object> seen = new HashMap<Object, Object>(); try { intern(seen, super.getErrorManager()); } catch (final SecurityException se) { reportError(se.getMessage(), se, ErrorManager.OPEN_FAILURE); } try { canidate = super.getFilter(); result = intern(seen, canidate); if (result != canidate) { super.setFilter(Filter.class.cast(result)); } canidate = super.getFormatter(); result = intern(seen, canidate); if (result != canidate) { super.setFormatter(Formatter.class.cast(result)); } } catch (final SecurityException se) { reportError(se.getMessage(), se, ErrorManager.OPEN_FAILURE); } canidate = this.subjectFormatter; result = intern(seen, canidate); if (result != canidate) { this.subjectFormatter = Formatter.class.cast(result); } canidate = this.pushFilter; result = intern(seen, canidate); if (result != canidate) { this.pushFilter = Filter.class.cast(result); } for (int i = 0; i < attachmentFormatters.length; ++i) { canidate = attachmentFormatters[i]; result = intern(seen, canidate); if (result != canidate) { attachmentFormatters[i] = Formatter.class.cast(result); } canidate = attachmentFilters[i]; result = intern(seen, canidate); if (result != canidate) { attachmentFilters[i] = Filter.class.cast(result); } canidate = attachmentNames[i]; result = intern(seen, canidate); if (result != canidate) { attachmentNames[i] = Formatter.class.cast(result); } } } catch (final Exception skip) { reportError(skip.getMessage(), skip, ErrorManager.OPEN_FAILURE); } } MailHandler();  MailHandler(final int capacity);  MailHandler(final Properties props); }
MailHandler extends Handler { private void intern() { assert Thread.holdsLock(this); try { Object canidate; Object result; final Map<Object, Object> seen = new HashMap<Object, Object>(); try { intern(seen, super.getErrorManager()); } catch (final SecurityException se) { reportError(se.getMessage(), se, ErrorManager.OPEN_FAILURE); } try { canidate = super.getFilter(); result = intern(seen, canidate); if (result != canidate) { super.setFilter(Filter.class.cast(result)); } canidate = super.getFormatter(); result = intern(seen, canidate); if (result != canidate) { super.setFormatter(Formatter.class.cast(result)); } } catch (final SecurityException se) { reportError(se.getMessage(), se, ErrorManager.OPEN_FAILURE); } canidate = this.subjectFormatter; result = intern(seen, canidate); if (result != canidate) { this.subjectFormatter = Formatter.class.cast(result); } canidate = this.pushFilter; result = intern(seen, canidate); if (result != canidate) { this.pushFilter = Filter.class.cast(result); } for (int i = 0; i < attachmentFormatters.length; ++i) { canidate = attachmentFormatters[i]; result = intern(seen, canidate); if (result != canidate) { attachmentFormatters[i] = Formatter.class.cast(result); } canidate = attachmentFilters[i]; result = intern(seen, canidate); if (result != canidate) { attachmentFilters[i] = Filter.class.cast(result); } canidate = attachmentNames[i]; result = intern(seen, canidate); if (result != canidate) { attachmentNames[i] = Formatter.class.cast(result); } } } catch (final Exception skip) { reportError(skip.getMessage(), skip, ErrorManager.OPEN_FAILURE); } } 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); }
MailHandler extends Handler { private void intern() { assert Thread.holdsLock(this); try { Object canidate; Object result; final Map<Object, Object> seen = new HashMap<Object, Object>(); try { intern(seen, super.getErrorManager()); } catch (final SecurityException se) { reportError(se.getMessage(), se, ErrorManager.OPEN_FAILURE); } try { canidate = super.getFilter(); result = intern(seen, canidate); if (result != canidate) { super.setFilter(Filter.class.cast(result)); } canidate = super.getFormatter(); result = intern(seen, canidate); if (result != canidate) { super.setFormatter(Formatter.class.cast(result)); } } catch (final SecurityException se) { reportError(se.getMessage(), se, ErrorManager.OPEN_FAILURE); } canidate = this.subjectFormatter; result = intern(seen, canidate); if (result != canidate) { this.subjectFormatter = Formatter.class.cast(result); } canidate = this.pushFilter; result = intern(seen, canidate); if (result != canidate) { this.pushFilter = Filter.class.cast(result); } for (int i = 0; i < attachmentFormatters.length; ++i) { canidate = attachmentFormatters[i]; result = intern(seen, canidate); if (result != canidate) { attachmentFormatters[i] = Formatter.class.cast(result); } canidate = attachmentFilters[i]; result = intern(seen, canidate); if (result != canidate) { attachmentFilters[i] = Filter.class.cast(result); } canidate = attachmentNames[i]; result = intern(seen, canidate); if (result != canidate) { attachmentNames[i] = Formatter.class.cast(result); } } } catch (final Exception skip) { reportError(skip.getMessage(), skip, ErrorManager.OPEN_FAILURE); } } 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);  }