Skip to content

Commit

Permalink
Merge pull request #883 from Vlatombe/readresolve-fix
Browse files Browse the repository at this point in the history
Call super method in `EC2AbstractSlave#readResolve()`
  • Loading branch information
res0nance authored Aug 31, 2023
2 parents 4e585c3 + 19e037d commit 9ea16c3
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/main/java/hudson/plugins/ec2/EC2AbstractSlave.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,26 +217,27 @@ public EC2AbstractSlave(String name, String instanceId, String templateDescripti

@Override
protected Object readResolve() {
var o = (EC2AbstractSlave) super.readResolve();
/*
* If instanceId is null, this object was deserialized from an old version of the plugin, where this field did
* not exist (prior to version 1.18). In those versions, the node name *was* the instance ID, so we can get it
* from there.
*/
if (instanceId == null) {
instanceId = getNodeName();
if (o.instanceId == null) {
o.instanceId = getNodeName();
}

if (amiType == null) {
amiType = new UnixData(rootCommandPrefix, slaveCommandPrefix, slaveCommandSuffix, Integer.toString(sshPort), null);
if (o.amiType == null) {
o.amiType = new UnixData(o.rootCommandPrefix, o.slaveCommandPrefix, o.slaveCommandSuffix, Integer.toString(o.sshPort), null);
}

if (maxTotalUses == 0) {
if (o.maxTotalUses == 0) {
EC2Cloud cloud = getCloud();
if (cloud != null) {
SlaveTemplate template = cloud.getTemplate(templateDescription);
SlaveTemplate template = cloud.getTemplate(o.templateDescription);
if (template != null) {
if (template.getMaxTotalUses() == -1) {
maxTotalUses = -1;
o.maxTotalUses = -1;
}
}
}
Expand All @@ -248,11 +249,11 @@ protected Object readResolve() {
* made Jenkins entirely unusable for some in the 1.50 release:
* https://issues.jenkins-ci.org/browse/JENKINS-62043
*/
if (terminateScheduled == null) {
terminateScheduled = new ResettableCountDownLatch(1, false);
if (o.terminateScheduled == null) {
o.terminateScheduled = new ResettableCountDownLatch(1, false);
}

return this;
return o;
}

public EC2Cloud getCloud() {
Expand Down

0 comments on commit 9ea16c3

Please sign in to comment.