Skip to content

Conversation

@jbescos
Copy link
Member

@jbescos jbescos commented Sep 23, 2025

#184

Do we remove this?:

@jbescos jbescos requested review from jmehrens and lukasj September 23, 2025 06:55
@jbescos jbescos force-pushed the issue184 branch 7 times, most recently from 9d85cef to a4a7e86 Compare September 23, 2025 07:14
…eclipse-ee4j#184

Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
@jmehrens
Copy link
Contributor

#184

Do we remove this?:

There are 2 options:

  1. Delete body except for the call to removing null handler from global. This makes the checks contextual to jdk.
  2. Delete the method completely and not enforce checks at all on old JDK.

@jmehrens
Copy link
Contributor

@jbescos For logging-mailhandler, in the last release I tried to make the security manager work operable on old JDKs and forward compatible with JDK25 to deal with missing, hostile, methods and classes. What you have coded up would have been the patch I would code for when Angus-Mail requires JDK25.

That said, the simplicity of not dealing with SecurityManager is nice.

Also SecurityException is not deprecated yet which is why I have certain catches. Especially for overridable methods like in java.lang.Thread which could unconditionally throw SecurityException without a SecurityManager.

@jbescos
Copy link
Member Author

jbescos commented Sep 24, 2025

OK, then we are good in Angus Mail for the time being and we don't need this PR so far. My understanding is, the main requirement is to not depend on SecurityManager, and we don't depend on it currently.

CC @lukasj . I think he wanted to get rid of AccessController and SecurityExceptions too.

@jmehrens
Copy link
Contributor

There still might be work to do in Angus Mail to align with JakartaEE. For logging-mailhandler, I try to support a wide range of JDKs down to min JDK. I'll try to do a proper review today.

*
* @param format the format pattern or null for default pattern.
* @throws SecurityException if a security manager exists and the caller
* does not have <code>LoggingPermission("control")</code>.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If SecurityException is removed then so should LoggingPermission as it was deprecated for removal. This will be repeated throughout logging package.

* named with '$' so WebappClassLoader.clearReferencesStaticFinal() method will
* ignore this field. However there is no standard documentation about this.
*/
private static final PrivilegedAction<Object> MAILHANDLER_LOADER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deleted comments explain why left hand side was an interface. I would rather get rid of the inner class and static reference. All this code does is a getAndSet of the context classloader with guards to make it a no-op in some cases. It was all to workaround the SecurityManager. A new method private static ClassLoader setContextClassLoader(ClassLoader l) with no short circuit would be clearer since SM is gone.

if (this.sealed) {
LogManagerProperties.checkLogManagerAccess();
} else {
throw new SecurityException("this-escape");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the type from SecurityException to java.lang.IllegalStateException. if that else condition is triggered the caller has access to a broken MailHander.

*/
private Object getAndSetContextClassLoader(final Object ccl) {
if (ccl != GetAndSetContext.NOT_MODIFIED) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change return and param to ClassLoader. Change body to simple implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants