-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Deprecating Extension.optional
#11201
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,7 +72,7 @@ | |
| @Retention(RUNTIME) | ||
| @Target({TYPE, FIELD, METHOD}) | ||
| @Documented | ||
| public @interface Extension { | ||
|
Check warning on line 75 in core/src/main/java/hudson/Extension.java
|
||
| /** | ||
| * Used for sorting extensions. | ||
| * | ||
|
|
@@ -87,7 +87,10 @@ | |
| /** | ||
| * If an extension is optional, don't log any class loading errors when reading it. | ||
| * @since 1.358 | ||
| * @deprecated This is very difficult to use correctly and rarely what you actually wanted. | ||
| * Use {@code OptionalExtension} from the {@code variant} plugin instead. | ||
| */ | ||
| @Deprecated | ||
| boolean optional() default false; | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ | |
| import com.sun.jna.Native; | ||
| import edu.umd.cs.findbugs.annotations.CheckForNull; | ||
| import edu.umd.cs.findbugs.annotations.NonNull; | ||
| import hudson.Extension; | ||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.logging.Level; | ||
| import java.util.logging.Logger; | ||
|
|
@@ -17,7 +16,6 @@ | |
| * @author Basil Crow | ||
| */ | ||
| @Restricted(NoExternalUse.class) | ||
| @Extension(optional = true) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unclear why this was “optional”. Of course this would only make sense on servers with systemd. But it would get loaded as an extension in all cases. |
||
| public class SystemdLifecycle extends ExitLifecycle { | ||
|
|
||
| private static final Logger LOGGER = Logger.getLogger(SystemdLifecycle.class.getName()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,8 +34,7 @@ | |
| * | ||
| * @author Kohsuke Kawaguchi | ||
| */ | ||
| @Extension(optional = true) @Symbol("hsErrPid") | ||
| // TODO why would an extension using a built-in extension point need to be marked optional? | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Who knows. |
||
| @Extension @Symbol("hsErrPid") | ||
| public class HsErrPidList extends AdministrativeMonitor { | ||
| /** | ||
| * hs_err_pid files that we think belong to us. | ||
|
|
||
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.
And
Lifecycledoes not even use the extension loader to begin with! TraditionallyExtensionPointwas just used as a very hand-wavy indicator for “things you might want to pay attention to in Javadoc as a plugin author”, rather than specifically meaning “a type which can be subtyped and marked with@Extensionto register”. (A broad category of such mistakes is placingExtensionPointon aDescribable. It is theDescriptorwhich is the extension point.)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.
Isn't that an indicator this should stay?
See also class Javadoc for
PluginServletFilterin which this quirk is made explicit.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.
jenkins/core/src/main/java/hudson/util/PluginServletFilter.java
Lines 57 to 58 in c9eaa5d
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.
The point stands, it's not just tradition, but also documented as such.
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.
Then we can correct the documentation: #11210
Uh oh!
There was an error while loading. Please reload this page.
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.
If the idea is that
ExtensionPointis only for things intended to be@Extension'ed, thenjenkins/core/src/main/java/hudson/ExtensionPoint.java
Lines 35 to 41 in c97fecc
PluginServletFilter), only adding a mention of@Extension.