Commit Graph
74 Commits
Author SHA1 Message Date
Basil Crow e27b310065 Enable whitespace-related Checkstyle checks (#6149) 2022-01-03 08:55:03 -08:00
Basil CrowandJames Nord 2ea1148286 Fix CatchingUnchecked Error Prone violations (#5950)
Co-authored-by: James Nord <jtnord@users.noreply.github.com>
2021-12-10 09:51:30 -08:00
Basil Crow 632033d6ad Sort imports (#5732) 2021-09-18 09:39:42 +01:00
Basil Crow 27d7acc810 Replace some anonymous classes with lambdas 2021-07-05 11:14:36 -07:00
Basil Crow 3542eed78e Prefer ArrayList and ArrayDeque to LinkedList (#5553) 2021-06-14 16:46:01 +01:00
Basil Crow 9f9ed7b60d Fix BadImport Error Prone violations (#5510)
* Fix `BadImport` Error Prone violations

* Fix Javadoc
2021-06-01 13:02:48 +08:00
Basil Crow ccaabe5adc Reduce usages of com.google.common.collect in favor of native Java functionality (#5464)
* Reduce usages of `com.google.common.collect` in favor of native Java functionality

* Copy original list to preserve original behavior
2021-05-10 11:40:21 +02:00
Basil Crow f6378676b1 Add missing @Override annotations (#5430) 2021-04-28 17:28:25 +08:00
Basil Crow 881365d30b Enable RedundantModifier Checkstyle check 2021-03-08 07:56:42 -08:00
Basil Crow 44c5342c58 Declare modifiers in JLS order (#5339) 2021-03-08 07:58:59 +00:00
Basil Crow 7fb2511ee8 Use native Java functionality rather than Guava's Lists#newArrayList, Maps#newHashMap, and Sets#newHashSet where possible 2021-02-25 17:02:24 -08:00
Tim JacombandJesse Glick ae88291731 [JENKINS-64423, JENKINS-46618] Resolve all core caused startup Illegal reflective access warnings (#5110)
Co-authored-by: Jesse Glick <jglick@cloudbees.com>
2021-01-06 08:04:40 +00:00
Basil Crow 05d0dffd25 Replace dangling Javadoc comment with block comment 2020-12-11 21:34:22 -08:00
Basil Crow 5d66c1a36e Remove unnecessary calls to Throwable#initCause() 2020-12-11 21:34:22 -08:00
a9ca5ef3d4 [JEP-227] Replace Acegi Security with Spring Security & upgrade Spring Framework (#4848)
Replacing Acegi Security with Spring Security

Co-authored-by: Tim Jacomb <timjacomb1+github@gmail.com>
Co-authored-by: James Nord <jtnord@users.noreply.github.com>
2020-11-06 11:30:25 -07:00
Jesse Glick a3a4a2e92d Reduce log level on notice about optional extensions 2020-04-01 16:15:41 -04:00
Jesse Glick 17c4c35813 [JENKINS-60816] Missing null check when traversing type hierarchy of interfaces 2020-01-21 15:53:19 -05:00
Jesse Glick e6e8c387d5 Prevent endless recursion in SezpozModule.resolve. 2020-01-04 20:14:13 -05:00
Vincent Latombe dd59e8c11c [JENKINS-60449] Attempt to fix an odd case of OptionalExtension blowing up Jenkins (#4393)
* Add new module optional-depender and a new failing test

* Variant plugin is a dependency of optional-depender

Optional-depender contains the following class

@OptionalExtension(requirePlugins = {"dependee"})
public class OptionalDependerExtension {
      private static void foo(Dependee d) {

      }
}

* [JENKINS-60449] Move plugin initialization at the end, keep only one extension refresh

* Improve logic to detect classloading issues

Inspect all declared constructors/methods/fields recursively to exclude
failing classes from Guice rather than have Guice explode.

This also fix the failing test, but the previous commit is still better
because it avoids an extra Jenkins.get().refreshExtensions() call.

* Only test resolveClass method if the classloader is not the bootstrap one
2020-01-03 23:26:35 +01:00
Basil Crow 861855953b Replace <code>…</code> with {@code …} 2019-10-19 14:02:59 -07:00
Josh Soref 11652016b0 IntelliJ/Java: Duplicate code -- Refactored as ExtensionFinder.getClassFromIndex (#4079)
* IntelliJ/Java: Duplicate code -- Refactored as ExtensionFinder.getClassFromIndex

* Adding braces around throw new AssertionError
2019-06-28 21:59:02 +02:00
Gustavo de Souza Bezerra 0e62b68012 [JENKINS-57678] - Change getInstance() (deprecated) to get() (#4042)
* Change getInstance() (deprecated) to get()

* Reverting modifications according review

* Changing for use the variable
2019-06-27 17:24:45 +02:00
Josh Soref 893e5c0891 Remove unused imports 2019-02-20 20:55:26 -05:00
Nicolas De loof c3988aae8a [JENKINS-52818] support @Postconstruct on extensions (#3570)
* add support for JSR250 @PostConstruct

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

* with PostConstruct method no need to explicitely invoke load() anymore

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

* introduce PersistentDescriptor to flag Descriptors
which expect load() to be invoked.

This prevent double execution for plugins which
have been designed on previous version of code and
don’t expect load to be automatically invoked.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

* document PostConstruct method discovery logic

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

* Force reflective access to non-public @PostConstruct methods

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

* check @PostConstruct annotation both on method and on implemented interface with a matching method.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

* typo

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2018-08-18 10:49:44 +02:00
Vincent Latombe 8c1b8b8e14 [JENKINS-50336] Fix loading optional extensions after installing a missing dependency (#3370)
* [JENKINS-50336] Only keep extensions that could be loaded in memory

So that delta computations will re-attempt to load any extension that
previously failed or was skipped after a new plugin is installed.

After installing a plugin, need to refresh extensions in order to pick
up extensions that can be loaded thanks to this new plugin.

* [JENKINS-50336] @OptionalExtension annotated classes were not being picked up after dynamic load of variant

Recompute GuiceExtensionAnnotation list when refreshing extensions
2018-06-08 19:30:11 +02:00
Daniel Beck 1e87a8fddb Reduce logging level of some warnings to INFO 2016-05-02 11:04:34 +02:00
Baptiste Mathus 8b3e4f43a2 Multi-catch refactoring when applicable 2016-04-12 10:17:42 +02:00
Jesse Glick 1a28593f09 [FIXED JENKINS-33772] ID was not sufficiently unique for SezpozModule; use an ID based on the actual annotated element. 2016-03-28 17:31:57 -04:00
Jesse Glick 1a2d82275c [FIXED JENKINS-25440] Recursively resolve @Inject’ed extensions, too, looking for LinkageError’s. 2016-02-29 15:17:05 -05:00
Jesse Glick fe2e448913 Replacing links to bugs.sun.com. 2016-02-16 16:46:38 -05:00
Kohsuke Kawaguchi c1a53a5f21 Formatting simplification for Java7 2015-12-20 10:54:33 -08:00
Christopher Simons 7efb9090dd remove unused import statements
In addition to cluttering the namespace, unused imports generate
compiler warnings, introducing noise and obscuring more important
compiler warnings.  This change removes them.
2015-11-10 10:13:52 -05:00
David Hoover 1709ed3a2e Add @Deprecated annotations to things documented as @deprecated. 2015-04-19 14:50:12 -07:00
Jesse Glick 22d433deae So far unsuccessful attempt to make Jenkins startup more robust against bugs like JENKINS-25440.
Even though SezpozModule.configure catches and ignores the faulty component, Guice still dies:
… hudson.ExtensionFinder$GuiceFinder <init>
SEVERE: Failed to create Guice container from all the plugins
com.google.inject.internal.guava.collect.$ComputationException: java.lang.NoClassDefFoundError: org/eclipse/jgit/storage/file/FileRepository
	at …
	at com.google.inject.Guice.createInjector(Guice.java:73)
	at hudson.ExtensionFinder$GuiceFinder.<init>(ExtensionFinder.java:279)
2014-11-04 17:45:52 -05:00
Jesse Glick 253943e13e [JENKINS-5756] Removing workarounds for HotSpot bug.
https://bugs.openjdk.java.net/browse/JDK-6933067 claims to be fixed as of Java 6, our baseline.
2014-09-24 09:32:50 -04:00
Jesse Glick 53d1e20f62 If an optional component cannot be loaded, print a polite one-line message, not a big scary stack trace.
(To reproduce: BuildNowTextPropertyTest from cloudbees-template warns about FolderProxyGroupContainer.)
2013-05-02 14:55:06 -04:00
Jesse Glick 4ab9c096bc Be more resilient against Guice errors.
com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance can throw NCDFE, it seems.
2012-09-20 17:58:33 -04:00
Kohsuke Kawaguchi 9a178aa8cc Added a mechanism to filter extension points as they are discovered.
I couldn't quite find one place to do this, so it's spread apart
somewhat.
2012-06-15 13:42:23 -07:00
Vojtech Juranek 6788f82a2c [FIXED JENKINS-13448] Added additional checks if Guice will be able to create injector to exclude missing extension poins. 2012-04-13 22:56:21 +02:00
Kohsuke Kawaguchi f19678d083 exposing major singletons to IoC 2012-02-29 15:23:20 -08:00
Kohsuke Kawaguchi a71d037b84 Revisited the way Guice creates an injector during unit test
The motivation of this is to enable test code to inject components from Jenkins, which means we need a single Injector that can see all of those, including @TestExtension and regular @Extension. Then I realized that the current implementation is broken, as it creates two independent Injectors. This has other undesirable side effects like @TestExtension components not being able to inject @Extensions, etc.

I briefly experimented with hierarchical Injectors (where we first create Injector that loads @Extension then create another that loads @TestExtension as a child), but this was hard to get right as we have no control over which ExtensionFinder gets instantiated first --- we'd be at the mercy of SezPoz.

So the eventual approach is to allow a single GuiceFinder to recognize multiple annotations. This also works well with our using child injector for installing plugins without restart
2012-02-09 12:18:05 -08:00
Kohsuke Kawaguchi 992158b67e filled in the real version 2011-11-28 17:01:22 -08:00
Kohsuke Kawaguchi a9be16e25e Cosmetic change 2011-11-15 21:18:55 -08:00
Kohsuke Kawaguchi 82ef72c00d Expose Injector to the rest of the world 2011-11-15 17:31:49 -08:00
Kohsuke Kawaguchi 09ef861c98 Step 1: make ExtensionFinder support refreshing 2011-11-15 17:31:49 -08:00
Kohsuke Kawaguchi 71cbf93a36 doc improvement 2011-10-27 06:35:21 -07:00
Kohsuke Kawaguchi ab421b59d2 [JENKINS-11279] Guice appears to throw RuntimeException sometimes. 2011-10-11 06:56:44 +09:00
Kohsuke Kawaguchi 87f89bc3ab [FIXED JENKINS-11279] more eager scouting 2011-10-11 06:56:44 +09:00
Kohsuke Kawaguchi 5d903514bd improve error recovery behaviour 2011-09-23 15:16:33 -07:00
Kohsuke Kawaguchi c1451269c3 follow up merge fixes 2011-09-21 22:00:38 -07:00