-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
[JENKINS-70206] Lazy initialization of JnlpSlaveAgentProtocol4
#7514
[JENKINS-70206] Lazy initialization of JnlpSlaveAgentProtocol4
#7514
Conversation
* @throws IOException if things go wrong. | ||
*/ | ||
public JnlpSlaveAgentProtocol4() throws KeyStoreException, KeyManagementException, IOException { | ||
private synchronized void init() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguably more legible just below handle
but this keeps the diff smaller.
init(); | ||
} catch (IOException x) { | ||
throw x; | ||
} catch (Exception x) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KeyStoreException, KeyManagementException
but also IllegalStateException
…just seemed simpler to catch anything.
@@ -175,11 +149,18 @@ public String getDisplayName() { | |||
|
|||
@Override | |||
public String getName() { | |||
return handler.getName(); | |||
return "JNLP4-connect"; // matches JnlpProtocol4Handler.getName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract to constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could, though this would require a new remoting
release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, missed the fact it was somewhere else.
try { | ||
init(); | ||
} catch (IOException x) { | ||
throw x; | ||
} catch (Exception x) { | ||
throw new IOException(x); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try { | |
init(); | |
} catch (IOException x) { | |
throw x; | |
} catch (Exception x) { | |
throw new IOException(x); | |
} | |
if (handler == null) { | |
try { | |
init(); | |
} catch (IOException x) { | |
throw x; | |
} catch (Exception x) { | |
throw new IOException(x); | |
} | |
} |
to avoid taking the object monitor in the general case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would have to think about whether that requires making handler
be volatile
. Does not seem necessary since handle
should be called once per actual agent connection, which is many orders of magnitude more expensive than acquiring an uncontended monitor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FTR this pattern would work, but as that page itself mentions, "in modern JVMs with efficient uncontended synchronization the performance difference is often negligible". The performance of the current version is certainly fine as described in the previous comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback. Please see the merge process documentation for more information about the merge process. Thanks!
See JENKINS-70206. Supersedes #7512.
Currently just unconditionally returning a value from
getName
, and lettinghandle
throw up any problems. We could try to disable the protocol (returnnull
fromgetName
) in case of problems, such as a missinginstance-identity
plugin (#6585), but that would be a bit more complicated, possibly cause extra work during startup even when this protocol is actually unused, and it is not clear to me that this would actually improve behavior for the user anyway.Testing done
Just relying on automated tests here. Not sure if we can tell whether the otherwise flaky test is more reliable with this patch.
Proposed changelog entries
Maintainer checklist
Before the changes are marked as
ready-for-merge
:upgrade-guide-needed
label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).lts-candidate
to be considered (see query).