Skip to content

Commit

Permalink
MailHander should catch ServiceConfigurationError #123
Browse files Browse the repository at this point in the history
Signed-off-by: jmehrens <jason_mehrens@hotmail.com>
  • Loading branch information
jmehrens committed Jan 31, 2024
1 parent ed8f3db commit 66442b0
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,9 @@ private void publish0(final LogRecord record) {
Message msg;
boolean priority;
synchronized (this) {
//No need to check for sealed as long as the init method ensures
//that data.length and capacity are both zero until end of init().
//size is always zero on construction.
if (size == data.length && size < capacity) {
grow();
}
Expand Down Expand Up @@ -1983,7 +1986,7 @@ protected void reportError(String msg, Exception ex, int code) {
* does not have {@code LoggingPermission("control")}.
*/
private void checkAccess() {
if (sealed) {
if (this.sealed) {
LogManagerProperties.checkLogManagerAccess();
} else {
throw new SecurityException("this-escape");
Expand Down Expand Up @@ -2304,7 +2307,7 @@ private synchronized void setCapacity0(int newCapacity) {
throw new IllegalStateException();
}

if (this.capacity == 0) {
if (!this.sealed || this.capacity == 0) {
return;
}

Expand All @@ -2315,7 +2318,7 @@ private synchronized void setCapacity0(int newCapacity) {
if (this.capacity < 0) { //If closed, remain closed.
this.capacity = -newCapacity;
} else {
this.push(false, ErrorManager.FLUSH_FAILURE);
push(false, ErrorManager.FLUSH_FAILURE);
this.capacity = newCapacity;
if (this.data.length > newCapacity) {
initLogRecords(1);
Expand Down Expand Up @@ -2448,9 +2451,9 @@ private boolean alignAttachmentFilters(int expect) {
private void reset() {
assert Thread.holdsLock(this);
if (size < data.length) {
Arrays.fill(data, 0, size, null);
Arrays.fill(data, 0, size, (LogRecord) null);
} else {
Arrays.fill(data, null);
Arrays.fill(data, (LogRecord) null);
}
this.size = 0;
}
Expand Down Expand Up @@ -2484,7 +2487,9 @@ private void grow() {
* @see #sealed
*/
private synchronized void init(final Properties props) {
initLogRecords(0); //Ensure non-null even on exception.
//Ensure non-null even on exception.
//Zero value allows publish to not check for this-escape.
initLogRecords(0);
LogManagerProperties.checkLogManagerAccess();

final String p = getClass().getName();
Expand Down Expand Up @@ -3097,7 +3102,6 @@ private void initFormatter(final String name) {
if (hasValue(name)) {
final Formatter f
= LogManagerProperties.newFormatter(name);
assert f != null;
if (f instanceof TailNameFormatter == false) {
formatter = f;
} else {
Expand Down Expand Up @@ -3319,7 +3323,7 @@ private void push(final boolean priority, final int code) {
releaseMutex();
}
} else {
reportUnPublishedError(null);
reportUnPublishedError((LogRecord) null);
}
}

Expand Down Expand Up @@ -3889,6 +3893,8 @@ private void saveChangesNoContent(final Message abort, final String msg) {
if (abort != null) {
try {
try {
//The abort message is non-null at this point so if any
//NPE is thrown then it was due to the call to saveChanges.
abort.saveChanges();
} catch (final NullPointerException xferEncoding) {
//Workaround GNU JavaMail bug in MimeUtility.getEncoding
Expand Down Expand Up @@ -4221,7 +4227,7 @@ private String descriptionFrom(Formatter f, Filter filter, Formatter name) {
*/
private String getClassId(final Formatter f) {
if (f == null) {
return "null";
return "no formatter";
}

if (f instanceof TailNameFormatter) {
Expand Down Expand Up @@ -4362,7 +4368,8 @@ private void appendContentLang(final MimePart p, final Locale l) {
try {
String lang = LogManagerProperties.toLanguageTag(l);
if (lang.length() != 0) {
String header = p.getHeader("Content-Language", null);
String header = p.getHeader("Content-Language",
(String) null);
if (isEmpty(header)) {
p.setHeader("Content-Language", lang);
} else if (!header.equalsIgnoreCase(lang)) {
Expand Down

0 comments on commit 66442b0

Please sign in to comment.