From 504ae9ce277614e88d9868c9bf7834c5a7484d7f Mon Sep 17 00:00:00 2001 From: Simon Brennecke Date: Wed, 1 Apr 2026 13:53:55 +0200 Subject: [PATCH] fix JENKINS-74824 / issue #1938 --- src/main/java/hudson/plugins/ec2/EC2Cloud.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/hudson/plugins/ec2/EC2Cloud.java b/src/main/java/hudson/plugins/ec2/EC2Cloud.java index a329cb6a4..4dcdc4974 100644 --- a/src/main/java/hudson/plugins/ec2/EC2Cloud.java +++ b/src/main/java/hudson/plugins/ec2/EC2Cloud.java @@ -415,6 +415,11 @@ public void addTemplate(SlaveTemplate newTemplate) throws Exception { throw new Exception( String.format("A SlaveTemplate with description %s already exists", newTemplateDescription)); } + if (newTemplate.parent != null) { + throw new Exception( + String.format("The new SlaveTemplate with description %s already has a parent", newTemplateDescription)); + } + newTemplate.parent = this; List templatesHolder = new ArrayList<>(templates); templatesHolder.add(newTemplate); templates = templatesHolder;