Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #12318 SecurityUtils should not elminate calls to existing methods #12319

Merged
merged 3 commits into from
Oct 22, 2024

Conversation

stoty
Copy link

@stoty stoty commented Sep 26, 2024

No description provided.

@sbordet sbordet requested a review from gregw October 17, 2024 08:29
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

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

I'm OK with the approach of "just call the methods if they exist and let the JVM work it out".

A couple of niggles...

@@ -93,8 +83,7 @@ public static Object getSecurityManager()
{
try
{
if (!USE_SECURITY_MANAGER)
return null;
// TODO cache this method on class loading like the other two methods ?
Copy link
Contributor

Choose a reason for hiding this comment

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

let's do this

@@ -113,8 +102,7 @@ public static Object getSecurityManager()
*/
public static void checkPermission(Permission permission) throws SecurityException
{
if (!USE_SECURITY_MANAGER)
return;
// TODO cache this methodon class loading like the other two methods ?
Copy link
Contributor

Choose a reason for hiding this comment

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

lets do this

@@ -142,9 +130,11 @@ public static void checkPermission(Permission permission) throws SecurityExcepti
*/
public static <T> T doPrivileged(PrivilegedAction<T> action)
{
if (!USE_SECURITY_MANAGER || doPrivileged == null)
// Keep this method short and inlineable.
MethodHandle methodHandle = doPrivileged;
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure why the local methodHandle variable is needed? doPrivileged is final.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure either, it's in 12.0 where I copied this from.
Perhaps its required for Java to automatically inline the function ? I don't know much about the automatic inlining behaviour.

I have removed it.

@stoty stoty force-pushed the revertUseSecurityManager branch from 3b4e520 to 0a25638 Compare October 18, 2024 16:24
@stoty
Copy link
Author

stoty commented Oct 18, 2024

Thank you for the review, I have tried to address your comments.

Shouldn't we use CAPS for the methodHandle constants ?

@gregw
Copy link
Contributor

gregw commented Oct 19, 2024

Shouldn't we use CAPS for the methodHandle constants ?

We have a bit of a mixed usage of CAPS for private static final fields, so I'd follow the style of the existing fields in this class.

@gregw
Copy link
Contributor

gregw commented Oct 19, 2024

@olamy can you look at CI failure? Doesn't look like a flake, but then doesn't look related to this PR either.

Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

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

This looks good, subject to CI clean build

@olamy olamy added the Bug For general bugs on Jetty side label Oct 21, 2024
@olamy
Copy link
Member

olamy commented Oct 22, 2024

@gregw build is fine
but @stoty need to sign Eclipse CLA

@stoty please have a read here https://www.eclipse.org/legal/eca/ once you have signed let us know and we will revalidate the PR

@stoty
Copy link
Author

stoty commented Oct 22, 2024

Thank you.
I have signed the ECA.

@olamy
Copy link
Member

olamy commented Oct 22, 2024

Thank you. I have signed the ECA.

@stoty perfect. PR validated Thanks!

@janbartel janbartel merged commit a8bb846 into jetty:jetty-12.1.x Oct 22, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants