Skip to content

Commit 09f3046

Browse files
committed
Deprecating Extension.optional
1 parent c44796d commit 09f3046

File tree

6 files changed

+7
-8
lines changed

6 files changed

+7
-8
lines changed

core/src/main/java/hudson/Extension.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@
8787
/**
8888
* If an extension is optional, don't log any class loading errors when reading it.
8989
* @since 1.358
90+
* @deprecated This is very difficult to use correctly and rarely what you actually wanted.
91+
* Use {@code OptionalExtension} from the {@code variant} plugin instead.
9092
*/
93+
@Deprecated
9194
boolean optional() default false;
9295

9396
/**

core/src/main/java/hudson/ExtensionFinder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public DefaultGuiceExtensionAnnotation() {
193193
super(Extension.class);
194194
}
195195

196+
@SuppressWarnings("deprecation")
196197
@Override
197198
protected boolean isOptional(Extension annotation) {
198199
return annotation.optional();
@@ -779,6 +780,7 @@ public void scout(Class extensionType, Hudson hudson) {
779780
}
780781
}
781782

783+
@SuppressWarnings("deprecation")
782784
private Level logLevel(IndexItem<Extension, Object> item) {
783785
return item.annotation().optional() ? Level.FINE : Level.WARNING;
784786
}

core/src/main/java/hudson/lifecycle/ExitLifecycle.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
package hudson.lifecycle;
2626

2727
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
28-
import hudson.Extension;
2928
import hudson.util.BootFailure;
3029
import java.util.logging.Level;
3130
import java.util.logging.Logger;
@@ -44,7 +43,6 @@
4443
* @author Alon Bar-Lev
4544
*/
4645
@Restricted(NoExternalUse.class)
47-
@Extension
4846
public class ExitLifecycle extends Lifecycle {
4947

5048
private static final Logger LOGGER = Logger.getLogger(ExitLifecycle.class.getName());

core/src/main/java/hudson/lifecycle/Lifecycle.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import edu.umd.cs.findbugs.annotations.CheckForNull;
2828
import edu.umd.cs.findbugs.annotations.NonNull;
29-
import hudson.ExtensionPoint;
3029
import hudson.Functions;
3130
import hudson.PluginManager;
3231
import hudson.Util;
@@ -62,7 +61,7 @@
6261
* @author Kohsuke Kawaguchi
6362
* @since 1.254
6463
*/
65-
public abstract class Lifecycle implements ExtensionPoint {
64+
public abstract class Lifecycle {
6665
private static Lifecycle INSTANCE = null;
6766

6867
/**

core/src/main/java/hudson/lifecycle/SystemdLifecycle.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.sun.jna.Native;
55
import edu.umd.cs.findbugs.annotations.CheckForNull;
66
import edu.umd.cs.findbugs.annotations.NonNull;
7-
import hudson.Extension;
87
import java.util.concurrent.TimeUnit;
98
import java.util.logging.Level;
109
import java.util.logging.Logger;
@@ -17,7 +16,6 @@
1716
* @author Basil Crow
1817
*/
1918
@Restricted(NoExternalUse.class)
20-
@Extension(optional = true)
2119
public class SystemdLifecycle extends ExitLifecycle {
2220

2321
private static final Logger LOGGER = Logger.getLogger(SystemdLifecycle.class.getName());

core/src/main/java/jenkins/diagnosis/HsErrPidList.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
*
3535
* @author Kohsuke Kawaguchi
3636
*/
37-
@Extension(optional = true) @Symbol("hsErrPid")
38-
// TODO why would an extension using a built-in extension point need to be marked optional?
37+
@Extension @Symbol("hsErrPid")
3938
public class HsErrPidList extends AdministrativeMonitor {
4039
/**
4140
* hs_err_pid files that we think belong to us.

0 commit comments

Comments
 (0)