From 1f170860fdee909543f48c19913ec3738d5168e6 Mon Sep 17 00:00:00 2001 From: Priya Date: Fri, 20 Dec 2024 14:59:11 +0530 Subject: [PATCH] [JENKINS-74964] Updating the Linkage error handling comment --- .../plugins/credentials/CredentialsSelectHelper.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/cloudbees/plugins/credentials/CredentialsSelectHelper.java b/src/main/java/com/cloudbees/plugins/credentials/CredentialsSelectHelper.java index 978d50ae..04ddfe5b 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/CredentialsSelectHelper.java +++ b/src/main/java/com/cloudbees/plugins/credentials/CredentialsSelectHelper.java @@ -38,7 +38,6 @@ import hudson.model.User; import hudson.security.AccessControlled; import hudson.security.Permission; - import java.io.IOException; import java.security.GeneralSecurityException; import java.util.ArrayList; @@ -623,8 +622,12 @@ public JSONObject doAddCredentials(StaplerRequest2 req, StaplerResponse2 rsp) th credentialsWereAdded = store.addCredentials(wrapper.getDomain(), credentials); } catch (LinkageError e) { /* - * Descriptor#newInstanceImpl throws a LinkageError if the constructor throws any exception other - * than HTTP response exceptions such as Descriptor.FormException. + * Descriptor#newInstanceImpl throws a LinkageError if the DataBoundConstructor or any DataBoundSetter + * throw any exception other than RuntimeException implementing HttpResponse. + * + * Checked exceptions implementing HttpResponse like FormException are wrapped and + * rethrown as HttpResponseException (a RuntimeException implementing HttpResponse) in + * RequestImpl#invokeConstructor. * * This approach is taken to maintain backward compatibility, as throwing a FormException directly * from the constructor would result in a source-incompatible change, potentially breaking dependent plugins.