diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 04e2248e67003..73ffa0896a398 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -19,7 +19,10 @@ If the issue is not fully described in the ticket, add more information here (ju
* ...
+The changelogs will be integrated by the core maintainers after the merge.
+The changelog entry should be in the imperative mood; e.g., write "do this"/"return that" rather than "does this"/"returns that".
+For examples, see: https://www.jenkins.io/changelog/
+-->
### Proposed upgrade guidelines
@@ -28,9 +31,10 @@ N/A
### Submitter checklist
- [ ] (If applicable) Jira issue is well described
-- [ ] Changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developer, depending on the change). [Examples](https://github.com/jenkins-infra/jenkins.io/blob/master/content/_data/changelogs/weekly.yml)
+- [ ] Changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developer, depending on the change) and are in the imperative mood. [Examples](https://github.com/jenkins-infra/jenkins.io/blob/master/content/_data/changelogs/weekly.yml)
* Fill-in the `Proposed changelog entries` section only if there are breaking changes or other changes which may require extra steps from users during the upgrade
- [ ] Appropriate autotests or explanation to why this change has no tests
+- [ ] New public classes, fields, and methods are annotated with `@Restricted` or have `@since TODO` Javadoc, as appropriate.
- [ ] For dependency updates: links to external changelogs and, if possible, full diffs
@@ -49,7 +53,7 @@ Before the changes are marked as `ready-for-merge`:
- [ ] There are at least 2 approvals for the pull request and no outstanding requests for change
- [ ] Conversations in the pull request are over OR it is explicit that a reviewer does not block the change
-- [ ] Changelog entries in the PR title and/or `Proposed changelog entries` are correct
+- [ ] Changelog entries in the PR title and/or `Proposed changelog entries` are accurate, human-readable, and in the imperative mood
- [ ] Proper changelog labels are set so that the changelog can be generated automatically
- [ ] If the change needs additional upgrade steps from users, `upgrade-guide-needed` label is set and there is a `Proposed upgrade guidelines` section in the PR title. ([example](https://github.com/jenkinsci/jenkins/pull/4387))
- [ ] If it would make sense to backport the change to LTS, a Jira issue must exist, be a _Bug_ or _Improvement_, and be labeled as `lts-candidate` to be considered (see [query](https://issues.jenkins-ci.org/issues/?filter=12146)).
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 9cec7116807de..2598142fdb152 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -23,6 +23,9 @@ updates:
- dependency-name: "javax.servlet.servlet-api"
# needs a jakarta upgrade project, imports changed
- dependency-name: "jakarta.servlet.jsp.jstl.jakarta.servlet.jsp.jstl-api"
+ # Starting with version 2.0.2, this library requires Java 11
+ - dependency-name: "org.glassfish.tyrus.bundles:tyrus-standalone-client-jdk"
+ versions: [">=2.0.2"]
# see https://github.com/jenkinsci/jenkins/pull/4224 can't be updated without breaking api
- dependency-name: "org.jfree:jfreechart"
# the dependency is actually provided by the Web container, hence it is aligned with Jetty. See https://github.com/jenkinsci/jenkins/pull/5211
@@ -34,7 +37,8 @@ updates:
# Must remain within jetty 9.x until Java 8 support is removed, ignore jetty 10.x and jetty 11.x updates
- dependency-name: "org.eclipse.jetty:jetty-maven-plugin"
versions: [">=10.0.0"]
- # Pending https://github.com/siom79/japicmp/pull/266
- - dependency-name: "com.github.siom79.japicmp:japicmp-maven-plugin"
# Winstone upgrades require multiple changes in pom.xml. See https://github.com/jenkinsci/jenkins/pull/5439#discussion_r616418468
- dependency-name: "org.jenkins-ci:winstone"
+ # Starting with version 10.0, this library requires Java 11
+ - dependency-name: "com.puppycrawl.tools:checkstyle"
+ versions: [">=10.0"]
diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml
index e7b74ccfd717d..10007762203c5 100644
--- a/.github/workflows/changelog.yml
+++ b/.github/workflows/changelog.yml
@@ -17,7 +17,7 @@ jobs:
# Drafts your next Release notes as Pull Requests are merged into "master"
- name: Generate GitHub Release Draft
id: release-drafter
- uses: release-drafter/release-drafter@v5.15.0
+ uses: release-drafter/release-drafter@v5.19.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Generates a YAML changelog file using https://github.com/jenkinsci/jenkins-core-changelog-generator
@@ -28,7 +28,7 @@ jobs:
env:
GITHUB_AUTH: github-actions:${{ secrets.GITHUB_TOKEN }}
- name: Upload Changelog YAML
- uses: actions/upload-artifact@v2.3.1
+ uses: actions/upload-artifact@v3
with:
name: changelog.yaml
path: changelog.yaml
@@ -44,7 +44,7 @@ jobs:
private_key: ${{ secrets.JENKINS_CHANGELOG_UPDATER_PRIVATE_KEY }}
repository: jenkins-infra/jenkins.io
- name: Check out
- uses: actions/checkout@v2.4.0
+ uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Publish jenkins.io changelog draft
diff --git a/.github/workflows/publish-release-artifact.yml b/.github/workflows/publish-release-artifact.yml
index 1d8277be3f2dd..7d2571883aec5 100644
--- a/.github/workflows/publish-release-artifact.yml
+++ b/.github/workflows/publish-release-artifact.yml
@@ -11,7 +11,7 @@ jobs:
project-version: ${{ steps.set-version.outputs.project-version }}
is-lts: ${{ steps.set-version.outputs.is-lts }}
steps:
- - uses: actions/checkout@v2.4.0
+ - uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml
index 43d62816190d2..a65d82e1b6479 100644
--- a/.mvn/extensions.xml
+++ b/.mvn/extensions.xml
@@ -2,6 +2,6 @@
io.jenkins.tools.incrementals
git-changelist-maven-extension
- 1.2
+ 1.3
diff --git a/.perltidyrc b/.perltidyrc
new file mode 100644
index 0000000000000..60845ad9c9cd1
--- /dev/null
+++ b/.perltidyrc
@@ -0,0 +1,104 @@
+#################################################
+# Categories outlined in this config
+# are based on the categories in the
+# perltidy man page:
+# http://perltidy.sourceforge.net/perltidy.html
+#################################################
+
+###################################
+# I/O Control
+###################################
+
+# Send all errors to standard output rather than a file.
+--standard-error-output
+
+# All non-critical warnings will be reported as errors.
+--warning-output
+
+###################################
+# Basic Options
+###################################
+
+# Maximum number of characters per line.
+--maximum-line-length=80
+
+###################################
+# Code Indentation Control
+###################################
+
+# The number of spaces to indent a line when a new block starts.
+--indent-columns=4
+
+# If a line continues, it should be indented 2 spaces.
+--continuation-indentation=4
+
+# If a comment is longer than the maximum line length, break it up for
+# readability.
+--outdent-long-comments
+
+# If a quoted string is longer than the maximum line length, do not break it up
+# for readability.
+--no-outdent-long-quotes
+
+###################################
+# Whitespace Control
+###################################
+
+# Stack opening braces in order to avoid having a brace sitting by itself on
+# a line.
+--stack-opening-tokens
+
+# Stack closing tokens in order to avoid having a brace sitting by itself on
+# a line.
+--stack-closing-tokens
+
+# Spaces between parentheses e.g. if ((my $len_tab = length($tabstr)) > 0) {
+--paren-tightness=2
+
+# Spaces between brackets e.g. $width = $col[$j + $k] - $col[$j];
+--square-bracket-tightness=2
+
+# Spaces between braces in expression e.g. $obj->{$parsed_sql->{'table'}[0]};
+--brace-tightness=2
+
+# Spaces between braches with blocks of code
+# e.g. %bf = map { $_ => -M $_ } grep { /\.deb$/ } dirents '.';
+--block-brace-tightness=0
+
+# Do not add spaces between semicolons within for loops.
+--nospace-for-semicolon
+
+###################################
+# Comment Controls
+###################################
+
+# Indent comments to be at the same level as the code.
+--indent-block-comments
+
+###################################
+# Line Break Control
+###################################
+
+# The else is on the same line as the brace.
+--cuddled-else
+
+# Create a break after -> and period if a break is required.
+--want-break-after='-> .'
+
+###################################
+# Blank Line Control
+###################################
+
+# Do not force blank lines before full line comments.
+--noblanks-before-comments
+
+# Do not force blank lines before blocks starting with for, foreach, while,
+# until, and if,unless.
+--noblanks-before-blocks
+
+###################################
+# Vertical Alignment
+###################################
+
+# Turn off vertical alignment.
+-novalign
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d981755ee1375..23053598b75a8 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -9,12 +9,10 @@ This page provides information about contributing code to the Jenkins core codeb
1. Fork the repository on GitHub
2. Clone the forked repository to your machine
3. Install the necessary development tools. In order to develop Jenkins, you need the following:
- * Java Development Kit (JDK) 8 or 11.
- In the Jenkins project we usually use [OpenJDK](http://openjdk.java.net/) or [AdoptOpenJDK](https://adoptopenjdk.net/), but you can use other JDKs as well.
- * For JDK 11 there might be some compatibility issues in developer tools,
- please see [this page](https://wiki.jenkins.io/display/JENKINS/Java+11+Developer+Guidelines#Java11DeveloperGuidelines-Knowndevelopertoolsissues) for more info.
- If you find a new issue, please report it with a `java11-devtools-compatibility` label in our issue tracker.
- * Maven 3.5.4 or above. You can [download Maven here].
+ * Java Development Kit (JDK) 11 or 8.
+ In the Jenkins project we usually use [Eclipse Adoptium](https://adoptium.net/) or [OpenJDK](https://openjdk.java.net/), but you can use other JDKs as well.
+ * Apache Maven 3.8.1 or above. You can [download Maven here].
+ In the Jenkins project we usually use the most recent Maven release.
* Any IDE which supports importing Maven projects.
* Install [NodeJS](https://nodejs.org/en/). **Note:** only needed to work on the frontend assets found in the `war` module.
* Frontend tasks are run using [yarn](https://yarnpkg.com/lang/en/). Run `npm install -g yarn` to install it.
@@ -92,7 +90,7 @@ cd war; yarn test
## Proposing Changes
The Jenkins project source code repositories are hosted at GitHub.
-All proposed changes are submitted, and code reviewed, using the _GitHub Pull Request_ process.
+All proposed changes are submitted, and code reviewed, using a [GitHub pull request] process.
To submit a pull request:
@@ -123,6 +121,7 @@ This will help minimize the diff, which makes reviewing PRs easier.
We also do not recommend `*` imports in the production code.
Please disable them in Settings > Editor > Codestyle > Java by setting _Class count to use import with '*'_ and Names count to use import with '*'_ to a high value, e.g. 100.
+
## Copyright
The Jenkins core is licensed under [MIT license], with a few exceptions in bundled classes.
@@ -150,15 +149,15 @@ just submit a pull request.
# Links
* [Jenkins Contribution Landing Page](https://www.jenkins.io/participate/)
-* [Jenkins IRC Channel](https://www.jenkins.io/chat/)
-* [Beginners Guide To Contributing](https://wiki.jenkins.io/display/JENKINS/Beginners+Guide+to+Contributing)
+* [Jenkins Chat Channels](https://www.jenkins.io/chat/)
+* [Beginners Guide To Contributing](https://www.jenkins.io/participate/)
* [List of newbie-friendly issues in the core](https://issues.jenkins.io/issues/?jql=project%20%3D%20JENKINS%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened)%20AND%20component%20%3D%20core%20AND%20labels%20in%20(newbie-friendly))
[Preparing for Plugin Development]: https://www.jenkins.io/doc/developer/tutorial/prepare/
[newbie friendly issues]: https://issues.jenkins.io/issues/?jql=project%20%3D%20JENKINS%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened)%20AND%20component%20%3D%20core%20AND%20labels%20in%20(newbie-friendly)
[Participate]: https://www.jenkins.io/participate/
[building and debugging process here]: https://www.jenkins.io/doc/developer/building/
-[guide]: https://wiki.jenkins.io/display/JENKINS/Starting+and+Accessing+Jenkins
+[guide]: https://www.jenkins.io/doc/book/installing/war-file/#run-the-war-file
[Remote Debug Flags]: https://stackoverflow.com/questions/975271/remote-debugging-a-java-application
[Acceptance Test Harness (ATH)]: https://github.com/jenkinsci/acceptance-test-harness
[backporting process]: https://www.jenkins.io/download/lts/
@@ -170,3 +169,4 @@ just submit a pull request.
[Jenkins Pipeline]: https://www.jenkins.io/doc/book/pipeline/
[Jenkinsfile]: ./Jenkinsfile
[download Maven here]: https://maven.apache.org/download.cgi
+[GitHub pull request]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests
\ No newline at end of file
diff --git a/Jenkinsfile b/Jenkinsfile
index 4cd19525f6e94..ba2eebe049214 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -7,129 +7,162 @@
def buildNumber = BUILD_NUMBER as int; if (buildNumber > 1) milestone(buildNumber - 1); milestone(buildNumber) // JENKINS-43353 / JENKINS-58625
-// TEST FLAG - to make it easier to turn on/off unit tests for speeding up access to later stuff.
-def runTests = true
def failFast = false
// Same memory sizing for both builds and ATH
-def javaOpts = ["JAVA_OPTS=-Xmx1536m -Xms512m","MAVEN_OPTS=-Xmx1536m -Xms512m"]
+def javaOpts = [
+ 'JAVA_OPTS=-Xmx1536m -Xms512m',
+ 'MAVEN_OPTS=-Xmx1536m -Xms512m',
+]
properties([
- buildDiscarder(logRotator(numToKeepStr: '50', artifactNumToKeepStr: '3')),
- disableConcurrentBuilds(abortPrevious: true)
+ buildDiscarder(logRotator(numToKeepStr: '50', artifactNumToKeepStr: '3')),
+ disableConcurrentBuilds(abortPrevious: true)
])
-// TODO: Restore 'Windows' once https://groups.google.com/forum/#!topic/jenkinsci-dev/v9d-XosOp2s is resolved
-def buildTypes = ['Linux']
-def jdks = [8, 11]
+def buildTypes = ['Linux', 'Windows']
+def jdks = [8, 11, 17]
def builds = [:]
-for(i = 0; i < buildTypes.size(); i++) {
-for(j = 0; j < jdks.size(); j++) {
+for (i = 0; i < buildTypes.size(); i++) {
+ for (j = 0; j < jdks.size(); j++) {
def buildType = buildTypes[i]
def jdk = jdks[j]
+ if (buildType == 'Windows' && jdk == 8) {
+ continue // unnecessary use of hardware
+ }
+ if (buildType == 'Windows' && jdk == 17) {
+ continue // TODO pending jenkins-infra/helpdesk#2822
+ }
builds["${buildType}-jdk${jdk}"] = {
- // see https://github.com/jenkins-infra/documentation/blob/master/ci.adoc#node-labels for information on what node types are available
- node(buildType == 'Linux' ? (jdk == 8 ? 'maven' : 'maven-11') : buildType.toLowerCase()) {
- // First stage is actually checking out the source. Since we're using Multibranch
- // currently, we can use "checkout scm".
- stage('Checkout') {
- checkout scm
- }
-
- def changelistF = "${pwd tmp: true}/changelist"
- def m2repo = "${pwd tmp: true}/m2repo"
+ // see https://github.com/jenkins-infra/documentation/blob/master/ci.adoc#node-labels for information on what node types are available
+ def agentContainerLabel = jdk == 8 ? 'maven' : 'maven-' + jdk
+ if (buildType == 'Windows') {
+ agentContainerLabel += '-windows'
+ }
+ node(agentContainerLabel) {
+ // First stage is actually checking out the source. Since we're using Multibranch
+ // currently, we can use "checkout scm".
+ stage('Checkout') {
+ checkout scm
+ }
- // Now run the actual build.
- stage("${buildType} Build / Test") {
- timeout(time: 300, unit: 'MINUTES') {
- // -Dmaven.repo.local=… tells Maven to create a subdir in the temporary directory for the local Maven repository
- // -ntp requires Maven >= 3.6.1
- def mvnCmd = "mvn -Pdebug -Pjapicmp -U -Dset.changelist help:evaluate -Dexpression=changelist -Doutput=$changelistF clean install ${runTests ? '-Dmaven.test.failure.ignore' : '-DskipTests'} -V -B -ntp -Dmaven.repo.local=$m2repo -Dspotbugs.failOnError=false -Dcheckstyle.failOnViolation=false -e"
- infra.runWithMaven(mvnCmd, jdk.toString(), javaOpts, true)
+ def changelistF = "${pwd tmp: true}/changelist"
+ def m2repo = "${pwd tmp: true}/m2repo"
- if(isUnix()) {
- sh 'git add . && git diff --exit-code HEAD'
- }
- }
- }
+ // Now run the actual build.
+ stage("${buildType} Build / Test") {
+ timeout(time: 5, unit: 'HOURS') {
+ realtimeJUnit(healthScaleFactor: 20.0, testResults: '*/target/surefire-reports/*.xml,war/junit.xml') {
+ def mavenOptions = [
+ '-Pdebug',
+ '--update-snapshots',
+ "-Dmaven.repo.local=$m2repo",
+ '-Dmaven.test.failure.ignore',
+ '-Dspotbugs.failOnError=false',
+ '-Dcheckstyle.failOnViolation=false',
+ '-Dset.changelist',
+ 'help:evaluate',
+ '-Dexpression=changelist',
+ "-Doutput=$changelistF",
+ 'clean',
+ 'install',
+ ]
+ infra.runMaven(mavenOptions, jdk.toString(), javaOpts, null, true)
+ if (isUnix()) {
+ sh 'git add . && git diff --exit-code HEAD'
+ }
+ }
+ }
+ }
- // Once we've built, archive the artifacts and the test results.
- stage("${buildType} Publishing") {
- if (runTests) {
- junit healthScaleFactor: 20.0, testResults: '*/target/surefire-reports/*.xml,war/junit.xml'
- archiveArtifacts allowEmptyArchive: true, artifacts: '**/target/surefire-reports/*.dumpstream'
- if (! fileExists('core/target/surefire-reports/TEST-jenkins.Junit4TestsRanTest.xml') ) {
- error 'junit 4 tests are no longer being run for the core package'
- }
- if (! fileExists('test/target/surefire-reports/TEST-jenkins.Junit4TestsRanTest.xml') ) {
- error 'junit 4 tests are no longer being run for the test package'
- } // cli has been migrated to junit 5
- if (failFast && currentBuild.result == 'UNSTABLE') {
- error 'There were test failures; halting early'
- }
- }
- if (buildType == 'Linux' && jdk == jdks[0]) {
- def folders = env.JOB_NAME.split('/')
- if (folders.length > 1) {
- discoverGitReferenceBuild(scm: folders[1])
- }
+ // Once we've built, archive the artifacts and the test results.
+ stage("${buildType} Publishing") {
+ archiveArtifacts allowEmptyArchive: true, artifacts: '**/target/surefire-reports/*.dumpstream'
+ if (!fileExists('core/target/surefire-reports/TEST-jenkins.Junit4TestsRanTest.xml')) {
+ error 'JUnit 4 tests are no longer being run for the core package'
+ }
+ if (!fileExists('test/target/surefire-reports/TEST-jenkins.Junit4TestsRanTest.xml')) {
+ error 'JUnit 4 tests are no longer being run for the test package'
+ }
+ // cli has been migrated to JUnit 5
+ if (failFast && currentBuild.result == 'UNSTABLE') {
+ error 'There were test failures; halting early'
+ }
+ if (buildType == 'Linux' && jdk == jdks[0]) {
+ def folders = env.JOB_NAME.split('/')
+ if (folders.length > 1) {
+ discoverGitReferenceBuild(scm: folders[1])
+ }
- echo "Recording static analysis results for '${buildType}'"
- recordIssues enabledForFailure: true,
- tools: [java(), javaDoc()],
- filters: [excludeFile('.*Assert.java')],
- sourceCodeEncoding: 'UTF-8',
- skipBlames: true,
- trendChartType: 'TOOLS_ONLY'
- recordIssues([tool: spotBugs(pattern: '**/target/spotbugsXml.xml'),
- sourceCodeEncoding: 'UTF-8',
- skipBlames: true,
- trendChartType: 'TOOLS_ONLY',
- qualityGates: [[threshold: 1, type: 'NEW', unstable: true]]])
- recordIssues([tool: checkStyle(pattern: '**/target/checkstyle-result.xml'),
- sourceCodeEncoding: 'UTF-8',
- skipBlames: true,
- trendChartType: 'TOOLS_ONLY',
- qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]]])
- if (failFast && currentBuild.result == 'UNSTABLE') {
- error 'Static analysis quality gates not passed; halting early'
- }
+ echo "Recording static analysis results for '${buildType}'"
+ recordIssues(
+ enabledForFailure: true,
+ tools: [java(), javaDoc()],
+ filters: [excludeFile('.*Assert.java')],
+ sourceCodeEncoding: 'UTF-8',
+ skipBlames: true,
+ trendChartType: 'TOOLS_ONLY'
+ )
+ recordIssues([tool: spotBugs(pattern: '**/target/spotbugsXml.xml'),
+ sourceCodeEncoding: 'UTF-8',
+ skipBlames: true,
+ trendChartType: 'TOOLS_ONLY',
+ qualityGates: [
+ [threshold: 1, type: 'NEW', unstable: true],
+ ]])
+ recordIssues([tool: checkStyle(pattern: '**/target/checkstyle-result.xml'),
+ sourceCodeEncoding: 'UTF-8',
+ skipBlames: true,
+ trendChartType: 'TOOLS_ONLY',
+ qualityGates: [
+ [threshold: 1, type: 'TOTAL', unstable: true],
+ ]])
+ if (failFast && currentBuild.result == 'UNSTABLE') {
+ error 'Static analysis quality gates not passed; halting early'
+ }
- def changelist = readFile(changelistF)
- dir(m2repo) {
- archiveArtifacts artifacts: "**/*$changelist/*$changelist*",
- excludes: '**/*.lastUpdated,**/jenkins-test*/',
- allowEmptyArchive: true, // in case we forgot to reincrementalify
- fingerprint: true
- }
- publishHTML([allowMissing: true, alwaysLinkToLastBuild: false, includes: 'japicmp.html', keepAll: false, reportDir: 'core/target/japicmp', reportFiles: 'japicmp.html', reportName: 'API compatibility', reportTitles: 'japicmp report'])
- }
- }
+ def changelist = readFile(changelistF)
+ dir(m2repo) {
+ archiveArtifacts(
+ artifacts: "**/*$changelist/*$changelist*",
+ excludes: '**/*.lastUpdated,**/jenkins-test*/',
+ allowEmptyArchive: true, // in case we forgot to reincrementalify
+ fingerprint: true
+ )
+ }
+ }
}
+ }
}
-}}
+ }
+}
-// TODO: Restore ATH once https://groups.google.com/forum/#!topic/jenkinsci-dev/v9d-XosOp2s is resolved
-// TODO: ATH flow now supports Java 8 only, it needs to be reworked (INFRA-1690)
builds.ath = {
- node("docker-highmem") {
- // Just to be safe
- deleteDir()
- def fileUri
- def metadataPath
- dir("sources") {
- checkout scm
- def mvnCmd = 'mvn --batch-mode --show-version -ntp -Pquick-build -am -pl war package -Dmaven.repo.local=$WORKSPACE_TMP/m2repo'
- infra.runWithMaven(mvnCmd, "8", javaOpts, true)
- dir("war/target") {
- fileUri = "file://" + pwd() + "/jenkins.war"
- }
- metadataPath = pwd() + "/essentials.yml"
- }
- dir("ath") {
- runATH jenkins: fileUri, metadataFile: metadataPath
- }
+ node('docker-highmem') {
+ // Just to be safe
+ deleteDir()
+ def fileUri
+ def metadataPath
+ dir('sources') {
+ checkout scm
+ def mavenOptions = [
+ '-Pquick-build',
+ '-Dmaven.repo.local=$WORKSPACE_TMP/m2repo',
+ '-am',
+ '-pl',
+ 'war',
+ 'package',
+ ]
+ infra.runMaven(mavenOptions, '11', javaOpts, null, true)
+ dir('war/target') {
+ fileUri = 'file://' + pwd() + '/jenkins.war'
+ }
+ metadataPath = pwd() + '/essentials.yml'
+ }
+ dir('ath') {
+ runATH jenkins: fileUri, metadataFile: metadataPath
}
+ }
}
builds.failFast = failFast
diff --git a/bom/pom.xml b/bom/pom.xml
index bb8ab745f8fdf..30e339c9bec3e 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -37,274 +37,262 @@ THE SOFTWARE.
Jenkins BOM
The module contains dependencies that are used by a specific Jenkins version
-
9.2
- 1.7.32
- 1593.v0e838714faae
+ 1.7.36
+ 1669.v95a_4b_919a_b_a_2
2.4.21
-
+
+ com.google.inject
+ guice-bom
+ 5.0.1
+ pom
+ import
+
+
+
org.springframework.security
spring-security-bom
- 5.6.0
+ 5.6.2
pom
import
- com.github.spotbugs
- spotbugs-annotations
- ${spotbugs-annotations.version}
+ antlr
+ antlr
+ 2.7.7
- net.jcip
- jcip-annotations
- 1.0
+
+ args4j
+ args4j
+ 2.33
- org.apache.ant
- ant
- 1.10.12
+ com.github.spotbugs
+ spotbugs-annotations
+ ${spotbugs-annotations.version}
- commons-io
- commons-io
- 2.11.0
+ com.google.guava
+ guava
+ 31.1-jre
- commons-lang
- commons-lang
- 2.6
+
+ com.jcraft
+ jzlib
+ 1.1.3-kohsuke-1
- commons-httpclient
- commons-httpclient
- 3.1-jenkins-3
+ com.sun.solaris
+ embedded_su4j
+ 1.1
- org.jenkins-ci.main
- remoting
- ${remoting.version}
+ com.sun.xml.txw2
+ txw2
+ 20110809
- com.google.guava
- guava
- 31.0.1-jre
+ com.thoughtworks.xstream
+ xstream
+ 1.4.19
- com.google.inject
- guice-bom
- 5.0.1
- pom
- import
+ commons-beanutils
+ commons-beanutils
+ 1.9.4
-
-
- org.slf4j
- slf4j-api
- ${slf4jVersion}
+ commons-codec
+ commons-codec
+ 1.15
- org.slf4j
- slf4j-jdk14
- ${slf4jVersion}
+ commons-collections
+ commons-collections
+ 3.2.2
- org.slf4j
- jcl-over-slf4j
- ${slf4jVersion}
+ commons-fileupload
+ commons-fileupload
+ 1.4
- commons-logging
- commons-logging
- 1.2
- provided
+ commons-httpclient
+ commons-httpclient
+ 3.1-jenkins-3
- org.slf4j
- log4j-over-slf4j
- ${slf4jVersion}
+ commons-io
+ commons-io
+ 2.11.0
- log4j
- log4j
- 1.2.17
- provided
+ commons-jelly
+ commons-jelly-tags-fmt
+ 1.0
- org.samba.jcifs
- jcifs
- 1.3.18-kohsuke-1
+ commons-jelly
+ commons-jelly-tags-xml
+ 1.1
- org.kohsuke
- access-modifier-annotation
- ${access-modifier.version}
+ commons-lang
+ commons-lang
+ 2.6
-
-
- javax.servlet
-
- servlet-api
- [0]
-
- provided
- true
+ io.jenkins.stapler
+ jenkins-stapler-support
+ 1.1
-
- commons-codec
- commons-codec
- 1.15
+ jakarta.servlet.jsp.jstl
+ jakarta.servlet.jsp.jstl-api
+ 1.2.7
-
- org.jenkins-ci
- annotation-indexer
- 1.15
+ jaxen
+ jaxen
+ 1.2.0
-
- org.jenkins-ci
- version-number
- 1.8
+ net.java.dev.jna
+ jna
+ 5.10.0
- org.jenkins-ci
- crypto-util
- 1.6
+ net.java.sezpoz
+ sezpoz
+ 1.13
- org.connectbot.jbcrypt
- jbcrypt
- 1.0.0
+ net.jcip
+ jcip-annotations
+ 1.0
- org.ow2.asm
- asm
- ${asm.version}
+ net.sf.kxml
+ kxml2
+ 2.3.0
- org.ow2.asm
- asm-analysis
- ${asm.version}
+ org.apache.ant
+ ant
+ 1.10.12
- org.ow2.asm
- asm-commons
- ${asm.version}
+ org.apache.commons
+ commons-compress
+ 1.21
- org.ow2.asm
- asm-tree
- ${asm.version}
+ org.codehaus.groovy
+ groovy-all
+ ${groovy.version}
- org.ow2.asm
- asm-util
- ${asm.version}
+ org.connectbot.jbcrypt
+ jbcrypt
+ 1.0.0
- com.github.jnr
- jnr-posix
- 3.1.14
+
+ org.fusesource.jansi
+ jansi
+ 1.11
- org.kohsuke
- windows-package-checker
- 1.2
+ org.jenkins-ci
+ annotation-indexer
+ 1.16
-
- args4j
- args4j
- 2.33
+
+ org.jenkins-ci
+ commons-jexl
+ 1.1-jenkins-20111212
org.jenkins-ci
- task-reactor
- 1.6
+ crypto-util
+ 1.7
- org.jvnet.localizer
- localizer
- 1.31
+ org.jenkins-ci
+ memory-monitor
+ 1.11
- antlr
- antlr
- 2.7.7
+ org.jenkins-ci
+ symbol-annotation
+ 1.1
- org.jfree
- jfreechart
- 1.0.19
+ org.jenkins-ci
+ task-reactor
+ 1.7
- commons-beanutils
- commons-beanutils
- 1.9.4
+ org.jenkins-ci
+ version-number
+ 1.9
- org.apache.commons
- commons-compress
- 1.21
+ org.jenkins-ci.main
+ remoting
+ ${remoting.version}
- commons-collections
- commons-collections
- 3.2.2
+ org.jenkins-ci.modules
+ instance-identity
+ 2.2
- commons-fileupload
- commons-fileupload
- 1.4
+ org.jenkins-ci.modules
+ launchd-slave-installer
+ 1.2
- com.sun.xml.txw2
- txw2
- 20110809
+ org.jenkins-ci.modules
+ slave-installer
+ 1.7
- org.jvnet.winp
- winp
- 1.28
+ org.jenkins-ci.modules
+ systemd-slave-installer
+ 1.1
- org.jenkins-ci
- memory-monitor
- 1.10
+ org.jenkins-ci.modules
+ upstart-slave-installer
+ 1.1
- net.java.dev.jna
- jna
- 5.10.0
+ org.jenkins-ci.modules
+ windows-slave-installer
+ 2.0
- com.sun.solaris
- embedded_su4j
- 1.1
+ org.jfree
+ jfreechart
+ 1.0.19
- net.java.sezpoz
- sezpoz
- 1.13
+ org.jvnet.hudson
+ commons-jelly-tags-define
+ 1.0.1-hudson-20071021
- org.kohsuke.jinterop
- j-interop
- 2.0.8-kohsuke-1
+ org.jvnet.localizer
+ localizer
+ 1.31
org.jvnet.robust-http-client
@@ -312,41 +300,30 @@ THE SOFTWARE.
1.2
- org.jenkins-ci
- symbol-annotation
- 1.1
+ org.jvnet.winp
+ winp
+ 1.28
- com.sun.mail
- jakarta.mail
- 1.6.5
+ org.kohsuke
+ access-modifier-annotation
+ ${access-modifier.version}
-
-
- com.thoughtworks.xstream
- xstream
- 1.4.18
+ org.kohsuke
+ windows-package-checker
+ 1.2
- net.sf.kxml
- kxml2
- 2.3.0
+ org.kohsuke.jinterop
+ j-interop
+ 2.0.8-kohsuke-1
-
-
- org.codehaus.groovy
- groovy-all
- ${groovy.version}
-
-
- org.fusesource.jansi
- jansi
- 1.11
+ org.kohsuke.stapler
+ json-lib
+ 2.4-jenkins-3
-
-
org.kohsuke.stapler
stapler
@@ -354,8 +331,8 @@ THE SOFTWARE.
org.kohsuke.stapler
- stapler-groovy
- ${stapler.version}
+ stapler-adjunct-codemirror
+ 1.3
org.kohsuke.stapler
@@ -364,88 +341,91 @@ THE SOFTWARE.
org.kohsuke.stapler
- stapler-adjunct-codemirror
- 1.3
-
-
- io.jenkins.stapler
- jenkins-stapler-support
- 1.1
-
-
- org.kohsuke.stapler
- json-lib
- 2.4-jenkins-3
+ stapler-groovy
+ ${stapler.version}
-
- com.jcraft
- jzlib
- 1.1.3-kohsuke-1
+ org.ow2.asm
+ asm
+ ${asm.version}
-
-
- commons-jelly
- commons-jelly-tags-fmt
- 1.0
+ org.ow2.asm
+ asm-analysis
+ ${asm.version}
- commons-jelly
- commons-jelly-tags-xml
- 1.1
+ org.ow2.asm
+ asm-commons
+ ${asm.version}
- org.jvnet.hudson
- commons-jelly-tags-define
- 1.0.1-hudson-20071021
+ org.ow2.asm
+ asm-tree
+ ${asm.version}
- org.jenkins-ci
- commons-jexl
- 1.1-jenkins-20111212
+ org.ow2.asm
+ asm-util
+ ${asm.version}
- jakarta.servlet.jsp.jstl
- jakarta.servlet.jsp.jstl-api
- 1.2.7
+ org.samba.jcifs
+ jcifs
+ 1.3.18-kohsuke-1
- jaxen
- jaxen
- 1.2.0
+ org.slf4j
+ jcl-over-slf4j
+ ${slf4jVersion}
-
-
- org.jenkins-ci.modules
- instance-identity
- 2.2
+ org.slf4j
+ log4j-over-slf4j
+ ${slf4jVersion}
- org.jenkins-ci.modules
- slave-installer
- 1.7
+
+ org.slf4j
+ slf4j-api
+ ${slf4jVersion}
- org.jenkins-ci.modules
- windows-slave-installer
- 2.0
+ org.slf4j
+ slf4j-jdk14
+ ${slf4jVersion}
- org.jenkins-ci.modules
- launchd-slave-installer
+
+ commons-logging
+ commons-logging
1.2
+ provided
- org.jenkins-ci.modules
- upstart-slave-installer
- 1.1
+
+
+ javax.servlet
+
+ servlet-api
+ [0]
+
+ provided
+ true
- org.jenkins-ci.modules
- systemd-slave-installer
- 1.1
+
+ log4j
+ log4j
+ 1.2.17
+ provided
@@ -464,10 +444,10 @@ THE SOFTWARE.
flatten
- process-resources
flatten
+ process-resources
bom
diff --git a/cli/pom.xml b/cli/pom.xml
index 0a296a810e000..c67f713b0e19a 100644
--- a/cli/pom.xml
+++ b/cli/pom.xml
@@ -32,41 +32,26 @@
- org.junit.jupiter
- junit-jupiter-api
- ${junit.jupiter.version}
- test
-
-
- org.junit.jupiter
- junit-jupiter-engine
- ${junit.jupiter.version}
- test
-
-
- org.junit.jupiter
- junit-jupiter
- ${junit.jupiter.version}
- test
-
-
- org.kohsuke
- access-modifier-annotation
- provided
+ commons-io
+ commons-io
+ true
- org.jenkins-ci
- annotation-indexer
+ commons-lang
+ commons-lang
true
- commons-io
- commons-io
+
+ net.i2p.crypto
+ eddsa
+ 0.3.0
true
- org.jvnet.localizer
- localizer
+ org.apache.sshd
+ sshd-common
+ ${mina-sshd.version}
true
@@ -76,38 +61,60 @@
true
- org.apache.sshd
- sshd-common
- ${mina-sshd.version}
+ org.glassfish.tyrus.bundles
+ tyrus-standalone-client-jdk
+ 2.0.1
true
-
- net.i2p.crypto
- eddsa
- 0.3.0
+ org.jenkins-ci
+ annotation-indexer
true
- org.slf4j
- slf4j-jdk14
+ org.jvnet.localizer
+ localizer
true
- org.glassfish.tyrus.bundles
- tyrus-standalone-client-jdk
- 2.0.1
+ org.slf4j
+ slf4j-jdk14
true
com.github.spotbugs
spotbugs-annotations
provided
+ true
+
+
+ com.google.code.findbugs
+ jsr305
+
+
- commons-lang
- commons-lang
- true
+ org.kohsuke
+ access-modifier-annotation
+ provided
+
+
+ org.junit.jupiter
+ junit-jupiter
+ ${junit.jupiter.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit.jupiter.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit.jupiter.version}
+ test
@@ -123,10 +130,10 @@
3.2.4
- package
shade
+ package
false
@@ -142,6 +149,14 @@
net
io.jenkins.cli.shaded.net
+
+ com
+ io.jenkins.cli.shaded.com
+
+
+ jakarta
+ io.jenkins.cli.shaded.jakarta
+
@@ -180,10 +195,10 @@
add-source
- generate-sources
add-source
+ generate-sources
diff --git a/cli/src/main/java/hudson/cli/CLI.java b/cli/src/main/java/hudson/cli/CLI.java
index 06baf6be13e6a..a6a33c6f800e9 100644
--- a/cli/src/main/java/hudson/cli/CLI.java
+++ b/cli/src/main/java/hudson/cli/CLI.java
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson.cli;
import static java.util.logging.Level.FINE;
@@ -80,9 +81,10 @@ private CLI() {}
* @throws NotTalkingToJenkinsException when connection is not made to Jenkins service.
*/
/*package*/ static void verifyJenkinsConnection(URLConnection c) throws IOException {
- if (c.getHeaderField("X-Hudson")==null && c.getHeaderField("X-Jenkins")==null)
+ if (c.getHeaderField("X-Hudson") == null && c.getHeaderField("X-Jenkins") == null)
throw new NotTalkingToJenkinsException(c);
}
+
/*package*/ static final class NotTalkingToJenkinsException extends IOException {
NotTalkingToJenkinsException(String s) {
super(s);
@@ -106,16 +108,17 @@ public static void main(final String[] _args) throws Exception {
}
}
- private enum Mode {HTTP, SSH, WEB_SOCKET}
+ private enum Mode { HTTP, SSH, WEB_SOCKET }
+
public static int _main(String[] _args) throws Exception {
List args = Arrays.asList(_args);
PrivateKeyProvider provider = new PrivateKeyProvider();
String url = System.getenv("JENKINS_URL");
- if (url==null)
+ if (url == null)
url = System.getenv("HUDSON_URL");
-
+
boolean noKeyAuth = false;
// TODO perhaps allow mode to be defined by environment variable too (assuming $JENKINS_USER_ID can be used for -user)
@@ -130,10 +133,10 @@ public static int _main(String[] _args) throws Exception {
boolean strictHostKey = false;
- while(!args.isEmpty()) {
+ while (!args.isEmpty()) {
String head = args.get(0);
if (head.equals("-version")) {
- System.out.println("Version: "+computeVersion());
+ System.out.println("Version: " + computeVersion());
return 0;
}
if (head.equals("-http")) {
@@ -167,9 +170,9 @@ public static int _main(String[] _args) throws Exception {
printUsage("-remoting mode is no longer supported");
return -1;
}
- if(head.equals("-s") && args.size()>=2) {
+ if (head.equals("-s") && args.size() >= 2) {
url = args.get(1);
- args = args.subList(2,args.size());
+ args = args.subList(2, args.size());
continue;
}
if (head.equals("-noCertificateCheck")) {
@@ -185,15 +188,15 @@ public boolean verify(String s, SSLSession sslSession) {
return true;
}
});
- args = args.subList(1,args.size());
+ args = args.subList(1, args.size());
continue;
}
if (head.equals("-noKeyAuth")) {
- noKeyAuth = true;
- args = args.subList(1,args.size());
- continue;
+ noKeyAuth = true;
+ args = args.subList(1, args.size());
+ continue;
}
- if(head.equals("-i") && args.size()>=2) {
+ if (head.equals("-i") && args.size() >= 2) {
File f = getFileFromArguments(args);
if (!f.exists()) {
printUsage(Messages.CLI_NoSuchFileExists(f));
@@ -202,7 +205,7 @@ public boolean verify(String s, SSLSession sslSession) {
provider.readFrom(f);
- args = args.subList(2,args.size());
+ args = args.subList(2, args.size());
continue;
}
if (head.equals("-strictHostKey")) {
@@ -239,7 +242,7 @@ public boolean verify(String s, SSLSession sslSession) {
break;
}
- if(url==null) {
+ if (url == null) {
printUsage(Messages.CLI_NoURL());
return -1;
}
@@ -263,7 +266,7 @@ public boolean verify(String s, SSLSession sslSession) {
url += '/';
}
- if(args.isEmpty())
+ if (args.isEmpty())
args = Collections.singletonList("help"); // default to help
if (mode == null) {
@@ -338,6 +341,7 @@ class CLIEndpoint extends Endpoint {
@Override
public void onOpen(Session session, EndpointConfig config) {}
}
+
class Authenticator extends ClientEndpointConfig.Configurator {
@Override
public void beforeRequest(Map> headers) {
@@ -346,6 +350,7 @@ public void beforeRequest(Map> headers) {
}
}
}
+
ClientManager client = ClientManager.createClient(JdkClientContainer.class.getName()); // ~ ContainerProvider.getWebSocketContainer()
client.getProperties().put(ClientProperties.REDIRECT_ENABLED, true); // https://tyrus-project.github.io/documentation/1.13.1/index/tyrus-proprietary-config.html#d0e1775
Session session = client.connectToServer(new CLIEndpoint(), ClientEndpointConfig.Builder.create().configurator(new Authenticator()).build(), URI.create(url.replaceFirst("^http", "ws") + "cli/ws"));
@@ -354,6 +359,7 @@ public void beforeRequest(Map> headers) {
public void send(byte[] data) throws IOException {
session.getBasicRemote().sendBinary(ByteBuffer.wrap(data));
}
+
@Override
public void close() throws IOException {
session.close();
@@ -479,7 +485,7 @@ private static String computeVersion() {
Properties props = new Properties();
try {
InputStream is = CLI.class.getResourceAsStream("/jenkins/cli/jenkins-cli-version.properties");
- if(is!=null) {
+ if (is != null) {
try {
props.load(is);
} finally {
@@ -489,7 +495,7 @@ private static String computeVersion() {
} catch (IOException e) {
e.printStackTrace(); // if the version properties is missing, that's OK.
}
- return props.getProperty("version","?");
+ return props.getProperty("version", "?");
}
/**
@@ -520,7 +526,7 @@ static String usage() {
}
private static void printUsage(String msg) {
- if(msg!=null) System.out.println(msg);
+ if (msg != null) System.out.println(msg);
System.err.println(usage());
}
diff --git a/cli/src/main/java/hudson/cli/CLIConnectionFactory.java b/cli/src/main/java/hudson/cli/CLIConnectionFactory.java
index eceff79eff3c7..9b4295b07cb34 100644
--- a/cli/src/main/java/hudson/cli/CLIConnectionFactory.java
+++ b/cli/src/main/java/hudson/cli/CLIConnectionFactory.java
@@ -1,10 +1,11 @@
package hudson.cli;
+import java.nio.charset.StandardCharsets;
import java.util.Base64;
/**
* Fluent-API to instantiate {@link CLI}.
- *
+ *
* @author Kohsuke Kawaguchi
*/
public class CLIConnectionFactory {
@@ -25,7 +26,7 @@ public CLIConnectionFactory authorization(String value) {
* Currently unused.
*/
public CLIConnectionFactory basicAuth(String username, String password) {
- return basicAuth(username+':'+password);
+ return basicAuth(username + ':' + password);
}
/**
@@ -33,7 +34,7 @@ public CLIConnectionFactory basicAuth(String username, String password) {
* Cf. {@code BasicHeaderApiTokenAuthenticator}.
*/
public CLIConnectionFactory basicAuth(String userInfo) {
- return authorization("Basic " + Base64.getEncoder().encodeToString(userInfo.getBytes()));
+ return authorization("Basic " + Base64.getEncoder().encodeToString(userInfo.getBytes(StandardCharsets.UTF_8)));
}
/**
diff --git a/cli/src/main/java/hudson/cli/DiagnosedStreamCorruptionException.java b/cli/src/main/java/hudson/cli/DiagnosedStreamCorruptionException.java
index 4708b425dbb77..a701cb3033474 100644
--- a/cli/src/main/java/hudson/cli/DiagnosedStreamCorruptionException.java
+++ b/cli/src/main/java/hudson/cli/DiagnosedStreamCorruptionException.java
@@ -41,14 +41,14 @@ public String toString() {
buf.append(super.toString()).append("\n");
buf.append("Read back: ").append(HexDump.toHex(readBack)).append('\n');
buf.append("Read ahead: ").append(HexDump.toHex(readAhead));
- if (diagnoseFailure!=null) {
+ if (diagnoseFailure != null) {
StringWriter w = new StringWriter();
PrintWriter p = new PrintWriter(w);
diagnoseFailure.printStackTrace(p);
p.flush();
buf.append("\nDiagnosis problem:\n ");
- buf.append(w.toString().trim().replace("\n","\n "));
+ buf.append(w.toString().trim().replace("\n", "\n "));
}
return buf.toString();
}
diff --git a/cli/src/main/java/hudson/cli/FlightRecorderInputStream.java b/cli/src/main/java/hudson/cli/FlightRecorderInputStream.java
index 4dc9700e9371e..5a1167c4fdc5d 100644
--- a/cli/src/main/java/hudson/cli/FlightRecorderInputStream.java
+++ b/cli/src/main/java/hudson/cli/FlightRecorderInputStream.java
@@ -52,13 +52,13 @@ public DiagnosedStreamCorruptionException analyzeCrash(Exception problem, String
final ByteArrayOutputStream readAhead = new ByteArrayOutputStream();
final IOException[] error = new IOException[1];
- Thread diagnosisThread = new Thread(diagnosisName+" stream corruption diagnosis thread") {
+ Thread diagnosisThread = new Thread(diagnosisName + " stream corruption diagnosis thread") {
@Override
public void run() {
int b;
try {
// not all InputStream will look for the thread interrupt flag, so check that explicitly to be defensive
- while (!Thread.interrupted() && (b=source.read())!=-1) {
+ while (!Thread.interrupted() && (b = source.read()) != -1) {
readAhead.write(b);
}
} catch (IOException e) {
@@ -81,14 +81,14 @@ public void run() {
if (diagnosisThread.isAlive())
diagnosisThread.interrupt(); // if it's not dead, kill
- return new DiagnosedStreamCorruptionException(problem,diagnosisProblem,getRecord(),readAhead.toByteArray());
+ return new DiagnosedStreamCorruptionException(problem, diagnosisProblem, getRecord(), readAhead.toByteArray());
}
@Override
public int read() throws IOException {
int i = source.read();
- if (i>=0)
+ if (i >= 0)
recorder.write(i);
return i;
}
@@ -96,8 +96,8 @@ public int read() throws IOException {
@Override
public int read(@NonNull byte[] b, int off, int len) throws IOException {
len = source.read(b, off, len);
- if (len>0)
- recorder.write(b,off,len);
+ if (len > 0)
+ recorder.write(b, off, len);
return len;
}
@@ -106,8 +106,8 @@ public int read(@NonNull byte[] b, int off, int len) throws IOException {
*/
@Override
public long skip(long n) throws IOException {
- byte[] buf = new byte[(int)Math.min(n,64*1024)];
- return read(buf,0,buf.length);
+ byte[] buf = new byte[(int) Math.min(n, 64 * 1024)];
+ return read(buf, 0, buf.length);
}
@Override
@@ -157,7 +157,7 @@ public synchronized byte[] toByteArray() {
System.arraycopy(data, 0, ret, capacity - pos, pos);
return ret;
}
-
+
/** @author @roadrunner2 */
@Override public synchronized void write(@NonNull byte[] buf, int off, int len) {
// no point in trying to copy more than capacity; this also simplifies logic below
diff --git a/cli/src/main/java/hudson/cli/FullDuplexHttpStream.java b/cli/src/main/java/hudson/cli/FullDuplexHttpStream.java
index fec9d7d3b9d3c..ae8917ab3aa6d 100644
--- a/cli/src/main/java/hudson/cli/FullDuplexHttpStream.java
+++ b/cli/src/main/java/hudson/cli/FullDuplexHttpStream.java
@@ -18,7 +18,7 @@
*/
public class FullDuplexHttpStream {
private final URL base;
-
+
private final OutputStream output;
private final InputStream input;
@@ -65,7 +65,7 @@ public FullDuplexHttpStream(URL base, String relativeTarget, String authorizatio
con.setDoOutput(true); // request POST to avoid caching
con.setRequestMethod("POST");
con.addRequestProperty("Session", uuid.toString());
- con.addRequestProperty("Side","download");
+ con.addRequestProperty("Side", "download");
if (authorization != null) {
con.addRequestProperty("Authorization", authorization);
}
@@ -83,11 +83,11 @@ public FullDuplexHttpStream(URL base, String relativeTarget, String authorizatio
con.setDoOutput(true); // request POST
con.setRequestMethod("POST");
con.setChunkedStreamingMode(0);
- con.setRequestProperty("Content-type","application/octet-stream");
+ con.setRequestProperty("Content-type", "application/octet-stream");
con.addRequestProperty("Session", uuid.toString());
- con.addRequestProperty("Side","upload");
+ con.addRequestProperty("Side", "upload");
if (authorization != null) {
- con.addRequestProperty ("Authorization", authorization);
+ con.addRequestProperty("Authorization", authorization);
}
output = con.getOutputStream();
LOGGER.fine("established upload side");
@@ -118,5 +118,5 @@ private URL tryToResolveRedirects(URL base, String authorization) {
static final int BLOCK_SIZE = 1024;
static final Logger LOGGER = Logger.getLogger(FullDuplexHttpStream.class.getName());
-
+
}
diff --git a/cli/src/main/java/hudson/cli/HexDump.java b/cli/src/main/java/hudson/cli/HexDump.java
index ad37158bc16d0..0132f47f130da 100644
--- a/cli/src/main/java/hudson/cli/HexDump.java
+++ b/cli/src/main/java/hudson/cli/HexDump.java
@@ -9,13 +9,14 @@ class HexDump {
private static final String CODE = "0123456789abcdef";
public static String toHex(byte[] buf) {
- return toHex(buf,0,buf.length);
+ return toHex(buf, 0, buf.length);
}
+
public static String toHex(byte[] buf, int start, int len) {
- StringBuilder r = new StringBuilder(len*2);
+ StringBuilder r = new StringBuilder(len * 2);
boolean inText = false;
- for (int i=0; i= 0x20 && b <= 0x7e) {
if (!inText) {
inText = true;
@@ -28,8 +29,8 @@ public static String toHex(byte[] buf, int start, int len) {
inText = false;
}
r.append("0x");
- r.append(CODE.charAt((b>>4)&15));
- r.append(CODE.charAt(b&15));
+ r.append(CODE.charAt((b >> 4) & 15));
+ r.append(CODE.charAt(b & 15));
if (i < len - 1) {
if (b == 10) {
r.append('\n');
diff --git a/cli/src/main/java/hudson/cli/PlainCLIProtocol.java b/cli/src/main/java/hudson/cli/PlainCLIProtocol.java
index 0c14433d10196..4f4fcfc49a664 100644
--- a/cli/src/main/java/hudson/cli/PlainCLIProtocol.java
+++ b/cli/src/main/java/hudson/cli/PlainCLIProtocol.java
@@ -73,6 +73,7 @@ private enum Op {
STDERR(false);
/** True if sent from the client to the server; false if sent from the server to the client. */
final boolean clientSide;
+
Op(boolean clientSide) {
this.clientSide = clientSide;
}
@@ -233,10 +234,12 @@ protected final OutputStream stream(final Op op) {
public void write(int b) throws IOException {
send(op, new byte[] {(byte) b});
}
+
@Override
public void write(@NonNull byte[] b, int off, int len) throws IOException {
send(op, b, off, len);
}
+
@Override
public void write(@NonNull byte[] b) throws IOException {
send(op, b);
diff --git a/cli/src/main/java/hudson/cli/PrivateKeyProvider.java b/cli/src/main/java/hudson/cli/PrivateKeyProvider.java
index 1ab1eff330498..64c84fc2074de 100644
--- a/cli/src/main/java/hudson/cli/PrivateKeyProvider.java
+++ b/cli/src/main/java/hudson/cli/PrivateKeyProvider.java
@@ -21,9 +21,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson.cli;
-import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.logging.Level.FINE;
import java.io.ByteArrayInputStream;
@@ -32,6 +32,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Paths;
@@ -110,15 +111,15 @@ public void readFrom(File keyFile) throws IOException, GeneralSecurityException
privateKeys.add(loadKey(keyFile, password));
}
- private static boolean isPemEncrypted(File f) throws IOException{
+ private static boolean isPemEncrypted(File f) throws IOException {
//simple check if the file is encrypted
return readPemFile(f).contains("4,ENCRYPTED");
}
- private static String askForPasswd(String filePath){
+ private static String askForPasswd(String filePath) {
Console cons = System.console();
String passwd = null;
- if (cons != null){
+ if (cons != null) {
char[] p = cons.readPassword("%s", "Enter passphrase for " + filePath + ":");
passwd = String.valueOf(p);
}
@@ -129,12 +130,12 @@ public static KeyPair loadKey(File f, String passwd) throws IOException, General
return loadKey(readPemFile(f), passwd);
}
- private static String readPemFile(File f) throws IOException{
+ private static String readPemFile(File f) throws IOException {
try (InputStream is = Files.newInputStream(f.toPath());
DataInputStream dis = new DataInputStream(is)) {
byte[] bytes = new byte[(int) f.length()];
dis.readFully(bytes);
- return new String(bytes);
+ return new String(bytes, StandardCharsets.UTF_8);
} catch (InvalidPathException e) {
throw new IOException(e);
}
@@ -143,7 +144,7 @@ private static String readPemFile(File f) throws IOException{
public static KeyPair loadKey(String pemString, String passwd) throws IOException, GeneralSecurityException {
Iterable itr = SecurityUtils.loadKeyPairIdentities(null,
new PathResource(Paths.get("key")),
- new ByteArrayInputStream(pemString.getBytes(UTF_8)),
+ new ByteArrayInputStream(pemString.getBytes(StandardCharsets.UTF_8)),
FilePasswordProvider.of(passwd));
long numLoaded = itr == null ? 0 : StreamSupport.stream(itr.spliterator(), false).count();
if (numLoaded <= 0) {
diff --git a/cli/src/main/java/hudson/cli/SSHCLI.java b/cli/src/main/java/hudson/cli/SSHCLI.java
index d9fa4911df84c..5badd296fbf0e 100644
--- a/cli/src/main/java/hudson/cli/SSHCLI.java
+++ b/cli/src/main/java/hudson/cli/SSHCLI.java
@@ -85,7 +85,7 @@ static int sshConnection(String jenkinsUrl, String user, List args, Priv
command.append(' ');
}
- try(SshClient client = SshClient.setUpDefaultClient()) {
+ try (SshClient client = SshClient.setUpDefaultClient()) {
KnownHostsServerKeyVerifier verifier = new DefaultKnownHostsServerKeyVerifier(new ServerKeyVerifier() {
@Override
@@ -116,7 +116,7 @@ public boolean verifyServerKey(ClientSession clientSession, SocketAddress remote
Set waitMask = channel.waitFor(Collections.singletonList(ClientChannelEvent.CLOSED), 0L);
- if(waitMask.contains(ClientChannelEvent.TIMEOUT)) {
+ if (waitMask.contains(ClientChannelEvent.TIMEOUT)) {
throw new SocketTimeoutException("Failed to retrieve command result in time: " + command);
}
diff --git a/cli/src/main/java/hudson/util/QuotedStringTokenizer.java b/cli/src/main/java/hudson/util/QuotedStringTokenizer.java
index 6b8a6f43f7811..6f77b758bc1f3 100644
--- a/cli/src/main/java/hudson/util/QuotedStringTokenizer.java
+++ b/cli/src/main/java/hudson/util/QuotedStringTokenizer.java
@@ -33,6 +33,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// ========================================================================
+
package hudson.util;
import java.util.ArrayList;
@@ -55,24 +56,24 @@
public class QuotedStringTokenizer
extends StringTokenizer
{
- private static final String __delim=" \t\n\r";
+ private static final String __delim = " \t\n\r";
private String _string;
private String _delim = __delim;
- private boolean _returnQuotes=false;
- private boolean _returnDelimiters=false;
+ private boolean _returnQuotes = false;
+ private boolean _returnDelimiters = false;
private StringBuilder _token;
- private boolean _hasToken=false;
- private int _i=0;
- private int _lastStart=0;
- private boolean _double=true;
- private boolean _single=true;
+ private boolean _hasToken = false;
+ private int _i = 0;
+ private int _lastStart = 0;
+ private boolean _double = true;
+ private boolean _single = true;
public static String[] tokenize(String str) {
return new QuotedStringTokenizer(str).toArray();
}
public static String[] tokenize(String str, String delimiters) {
- return new QuotedStringTokenizer(str,delimiters).toArray();
+ return new QuotedStringTokenizer(str, delimiters).toArray();
}
/* ------------------------------------------------------------ */
@@ -94,17 +95,17 @@ public QuotedStringTokenizer(String str,
boolean returnQuotes)
{
super("");
- _string=str;
- if (delim!=null)
- _delim=delim;
- _returnDelimiters=returnDelimiters;
- _returnQuotes=returnQuotes;
+ _string = str;
+ if (delim != null)
+ _delim = delim;
+ _returnDelimiters = returnDelimiters;
+ _returnQuotes = returnQuotes;
- if (_delim.indexOf('\'')>=0 ||
- _delim.indexOf('"')>=0)
- throw new Error("Can't use quotes as delimiters: "+_delim);
+ if (_delim.indexOf('\'') >= 0 ||
+ _delim.indexOf('"') >= 0)
+ throw new Error("Can't use quotes as delimiters: " + _delim);
- _token=new StringBuilder(_string.length()>1024?512:_string.length()/2);
+ _token = new StringBuilder(_string.length() > 1024 ? 512 : _string.length() / 2);
}
/* ------------------------------------------------------------ */
@@ -112,25 +113,25 @@ public QuotedStringTokenizer(String str,
String delim,
boolean returnDelimiters)
{
- this(str,delim,returnDelimiters,false);
+ this(str, delim, returnDelimiters, false);
}
/* ------------------------------------------------------------ */
public QuotedStringTokenizer(String str,
String delim)
{
- this(str,delim,false,false);
+ this(str, delim, false, false);
}
/* ------------------------------------------------------------ */
public QuotedStringTokenizer(String str)
{
- this(str,null,false,false);
+ this(str, null, false, false);
}
public String[] toArray() {
List r = new ArrayList<>();
- while(hasMoreTokens())
+ while (hasMoreTokens())
r.add(nextToken());
return r.toArray(new String[r.size()]);
}
@@ -144,75 +145,75 @@ public boolean hasMoreTokens()
if (_hasToken)
return true;
- _lastStart=_i;
+ _lastStart = _i;
- int state=0;
- boolean escape=false;
- while (_i<_string.length())
+ int state = 0;
+ boolean escape = false;
+ while (_i < _string.length())
{
- char c=_string.charAt(_i++);
+ char c = _string.charAt(_i++);
switch (state)
{
case 0: // Start
- if(_delim.indexOf(c)>=0)
+ if (_delim.indexOf(c) >= 0)
{
if (_returnDelimiters)
{
_token.append(c);
- return _hasToken=true;
+ return _hasToken = true;
}
}
- else if (c=='\'' && _single)
+ else if (c == '\'' && _single)
{
if (_returnQuotes)
_token.append(c);
- state=2;
+ state = 2;
}
- else if (c=='\"' && _double)
+ else if (c == '\"' && _double)
{
if (_returnQuotes)
_token.append(c);
- state=3;
+ state = 3;
}
else
{
_token.append(c);
- _hasToken=true;
- state=1;
+ _hasToken = true;
+ state = 1;
}
continue;
case 1: // Token
- _hasToken=true;
+ _hasToken = true;
if (escape)
{
- escape=false;
- if(ESCAPABLE_CHARS.indexOf(c)<0)
+ escape = false;
+ if (ESCAPABLE_CHARS.indexOf(c) < 0)
_token.append('\\');
_token.append(c);
}
- else if(_delim.indexOf(c)>=0)
+ else if (_delim.indexOf(c) >= 0)
{
if (_returnDelimiters)
_i--;
return _hasToken;
}
- else if (c=='\'' && _single)
+ else if (c == '\'' && _single)
{
if (_returnQuotes)
_token.append(c);
- state=2;
+ state = 2;
}
- else if (c=='\"' && _double)
+ else if (c == '\"' && _double)
{
if (_returnQuotes)
_token.append(c);
- state=3;
+ state = 3;
}
- else if (c=='\\')
+ else if (c == '\\')
{
- escape=true;
+ escape = true;
}
else
_token.append(c);
@@ -220,25 +221,25 @@ else if (c=='\\')
case 2: // Single Quote
- _hasToken=true;
+ _hasToken = true;
if (escape)
{
- escape=false;
- if(ESCAPABLE_CHARS.indexOf(c)<0)
+ escape = false;
+ if (ESCAPABLE_CHARS.indexOf(c) < 0)
_token.append('\\');
_token.append(c);
}
- else if (c=='\'')
+ else if (c == '\'')
{
if (_returnQuotes)
_token.append(c);
- state=1;
+ state = 1;
}
- else if (c=='\\')
+ else if (c == '\\')
{
if (_returnQuotes)
_token.append(c);
- escape=true;
+ escape = true;
}
else
_token.append(c);
@@ -246,25 +247,25 @@ else if (c=='\\')
case 3: // Double Quote
- _hasToken=true;
+ _hasToken = true;
if (escape)
{
- escape=false;
- if(ESCAPABLE_CHARS.indexOf(c)<0)
+ escape = false;
+ if (ESCAPABLE_CHARS.indexOf(c) < 0)
_token.append('\\');
_token.append(c);
}
- else if (c=='\"')
+ else if (c == '\"')
{
if (_returnQuotes)
_token.append(c);
- state=1;
+ state = 1;
}
- else if (c=='\\')
+ else if (c == '\\')
{
if (_returnQuotes)
_token.append(c);
- escape=true;
+ escape = true;
}
else
_token.append(c);
@@ -283,11 +284,11 @@ else if (c=='\\')
public String nextToken()
throws NoSuchElementException
{
- if (!hasMoreTokens() || _token==null)
+ if (!hasMoreTokens() || _token == null)
throw new NoSuchElementException();
- String t=_token.toString();
+ String t = _token.toString();
_token.setLength(0);
- _hasToken=false;
+ _hasToken = false;
return t;
}
@@ -296,10 +297,10 @@ public String nextToken()
public String nextToken(String delim)
throws NoSuchElementException
{
- _delim=delim;
- _i=_lastStart;
+ _delim = delim;
+ _i = _lastStart;
_token.setLength(0);
- _hasToken=false;
+ _hasToken = false;
return nextToken();
}
@@ -338,19 +339,19 @@ public int countTokens()
*/
public static String quote(String s, String delim)
{
- if (s==null)
+ if (s == null)
return null;
- if (s.length()==0)
+ if (s.length() == 0)
return "\"\"";
- for (int i=0;i=0)
+ if (c == '\\' || c == '"' || c == '\'' || Character.isWhitespace(c) || delim.indexOf(c) >= 0)
{
- StringBuffer b=new StringBuffer(s.length()+8);
- quote(b,s);
+ StringBuffer b = new StringBuffer(s.length() + 8);
+ quote(b, s);
return b.toString();
}
}
@@ -368,13 +369,13 @@ public static String quote(String s, String delim)
*/
public static String quote(String s)
{
- if (s==null)
+ if (s == null)
return null;
- if (s.length()==0)
+ if (s.length() == 0)
return "\"\"";
- StringBuffer b=new StringBuffer(s.length()+8);
- quote(b,s);
+ StringBuffer b = new StringBuffer(s.length() + 8);
+ quote(b, s);
return b.toString();
}
@@ -388,13 +389,13 @@ public static String quote(String s)
*/
public static void quote(StringBuffer buf, String s)
{
- synchronized(buf)
+ synchronized (buf)
{
buf.append('"');
- for (int i=0;i= '0' && b <= '9') return (byte) (b - '0');
if (b >= 'a' && b <= 'f') return (byte) (b - 'a' + 10);
@@ -546,7 +547,7 @@ public static byte convertHexDigit( byte b )
*
* Others, like, say, \W will be left alone instead of becoming just W.
* This is important to keep Hudson behave on Windows, which uses '\' as
- * the directory separator.
+ * the directory separator.
*/
private static final String ESCAPABLE_CHARS = "\\\"' ";
}
diff --git a/cli/src/main/resources/hudson/cli/client/Messages_pt_BR.properties b/cli/src/main/resources/hudson/cli/client/Messages_pt_BR.properties
index 84f4b80bb04d7..b2a4bfac065a8 100644
--- a/cli/src/main/resources/hudson/cli/client/Messages_pt_BR.properties
+++ b/cli/src/main/resources/hudson/cli/client/Messages_pt_BR.properties
@@ -20,17 +20,17 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-CLI.VersionMismatch=A vers\u00e3o n\u00e3o coincide. Esta CLI n\u00e3o pode funcionar com este servidor Jenkins
CLI.Usage=Jenkins CLI\n\
- Uso: java -jar jenkins-cli.jar [-s URL] comando [op\u00e7\u00f5es...] par\u00e2metros...\n\
- Op\u00e7\u00f5es:\n\
- -s URL : a URL do servidor (por padr\u00e3o a vari\u00e1vel de ambiente JENKINS_URL \u00e9 usada)\n\
- -i KEY : arquivo contendo a chave SSH privada usada para autentica\u00e7\u00e3o\n\
+ Uso: java -jar jenkins-cli.jar [-s URL] comando [op\u00E7\u00F5es...] par\u00E2metros...\n\
+ Op\u00E7\u00F5es:\n\
+ -s URL : a URL do servidor (por padr\u00E3o a vari\u00E1vel de ambiente JENKINS_URL \u00E9 usada)\n\
+ -i KEY : arquivo contendo a chave SSH privada usada para autentica\u00E7\u00E3o\n\
-p HOST:PORT : host e porta do proxy HTTP para tunelamento de proxy HTTPS. Veja https://www.jenkins.io/redirect/cli-https-proxy-tunnel\n\
- -noCertificateCheck : ignora completamente a valida\u00e7\u00e3o dos certificados HTTPS. Use com cautela\n\
- -noKeyAuth : n\u00e3o tenta carregar a chave privada para autentica\u00e7\u00e3o SSH. Conflita com -i\n\
+ -noCertificateCheck : ignora completamente a valida\u00E7\u00E3o dos certificados HTTPS. Use com cautela\n\
+ -noKeyAuth : n\u00E3o tenta carregar a chave privada para autentica\u00E7\u00E3o SSH. Conflita com -i\n\
\n\
- Os comandos dispon\u00edveis dependem do servidor. Execute o comando 'help' para\n\
+ Os comandos dispon\u00EDveis dependem do servidor. Execute o comando 'help' para\n\
ver a lista.
-CLI.NoURL=N\u00e3o foi especificado nem '-s' e nem a vari\u00e1vel de ambiente JENKINS_URL
-CLI.NoSuchFileExists=O arquivo n\u00e3o existe: {0}
+CLI.NoURL=N\u00E3o foi especificado nem '-s' e nem a vari\u00E1vel de ambiente JENKINS_URL
+CLI.NoSuchFileExists=O arquivo n\u00E3o existe: {0}
+CLI.BadAuth=As vari\u00E1veis de ambiente JENKINS_USER_ID e JENKINS_API_TOKEN precisam ser ambas configuradas ou deixadas vazias.
diff --git a/cli/src/test/java/hudson/cli/HexDumpTest.java b/cli/src/test/java/hudson/cli/HexDumpTest.java
index 52b6c2e631f41..9e15de1453cbc 100644
--- a/cli/src/test/java/hudson/cli/HexDumpTest.java
+++ b/cli/src/test/java/hudson/cli/HexDumpTest.java
@@ -24,9 +24,9 @@ public void testToHex1(String expected, byte[] buf) {
static Stream testToHex1Sources() {
return Stream.of(
arguments("'fooBar'", new byte[] {'f', 'o', 'o', 'B', 'a', 'r'}),
- arguments("0xc3", new byte[] {(byte)'Ã'}),
- arguments("0xac '100'", new byte[] {(byte)'€', '1', '0', '0'}),
- arguments("'1' 0xf7 '2'", new byte[] {'1', (byte)'÷', '2'}),
+ arguments("0xc3", new byte[] {(byte) 'Ã'}),
+ arguments("0xac '100'", new byte[] {(byte) '€', '1', '0', '0'}),
+ arguments("'1' 0xf7 '2'", new byte[] {'1', (byte) '÷', '2'}),
arguments("'foo' 0x0a\n'Bar'", new byte[] {'f', 'o', 'o', '\n', 'B', 'a', 'r'})
);
}
@@ -41,9 +41,9 @@ public void testToHex2(String expected, byte[] buf, int start, int len) {
static Stream testToHex2Sources() {
return Stream.of(
arguments("'ooBa'", new byte[] {'f', 'o', 'o', 'B', 'a', 'r'}, 1, 4),
- arguments("0xc3", new byte[] {(byte)'Ã'}, 0, 1),
- arguments("0xac '10'", new byte[] {(byte)'€', '1', '0', '0'}, 0, 3),
- arguments("0xf7 '2'", new byte[] {'1', (byte)'÷', '2'}, 1, 2),
+ arguments("0xc3", new byte[] {(byte) 'Ã'}, 0, 1),
+ arguments("0xac '10'", new byte[] {(byte) '€', '1', '0', '0'}, 0, 3),
+ arguments("0xf7 '2'", new byte[] {'1', (byte) '÷', '2'}, 1, 2),
arguments("'Bar'", new byte[] {'f', 'o', 'o', '\n', 'B', 'a', 'r'}, 4, 3),
arguments("", new byte[] {'f', 'o', 'o', 'B', 'a', 'r'}, 0, 0)
);
diff --git a/cli/src/test/java/hudson/cli/PlainCLIProtocolTest.java b/cli/src/test/java/hudson/cli/PlainCLIProtocolTest.java
index 3eb29728fd71b..98a4fefd8001f 100644
--- a/cli/src/test/java/hudson/cli/PlainCLIProtocolTest.java
+++ b/cli/src/test/java/hudson/cli/PlainCLIProtocolTest.java
@@ -31,6 +31,7 @@
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
+import java.nio.charset.Charset;
import org.junit.jupiter.api.Test;
public class PlainCLIProtocolTest {
@@ -42,27 +43,34 @@ public void ignoreUnknownOperations() throws Exception {
class Client extends PlainCLIProtocol.ClientSide {
int code = -1;
final ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+
Client() throws IOException {
super(new PlainCLIProtocol.FramedOutput(upload));
}
+
@Override
protected synchronized void onExit(int code) {
this.code = code;
notifyAll();
}
+
@Override
protected void onStdout(byte[] chunk) throws IOException {
stdout.write(chunk);
}
+
@Override
protected void onStderr(byte[] chunk) throws IOException {}
+
@Override
protected void handleClose() {}
+
void send() throws IOException {
sendArg("command");
sendStart();
- streamStdin().write("hello".getBytes());
+ streamStdin().write("hello".getBytes(Charset.defaultCharset()));
}
+
void newop() throws IOException {
DataOutputStream dos = new DataOutputStream(upload);
dos.writeInt(0);
@@ -70,26 +78,33 @@ void newop() throws IOException {
dos.flush();
}
}
+
class Server extends PlainCLIProtocol.ServerSide {
String arg;
boolean started;
final ByteArrayOutputStream stdin = new ByteArrayOutputStream();
+
Server() throws IOException {
super(new PlainCLIProtocol.FramedOutput(download));
}
+
@Override
protected void onArg(String text) {
arg = text;
}
+
@Override
protected void onLocale(String text) {}
+
@Override
protected void onEncoding(String text) {}
+
@Override
protected synchronized void onStart() {
started = true;
notifyAll();
}
+
@Override
protected void onStdin(byte[] chunk) throws IOException {
/* To inject a race condition:
@@ -101,14 +116,18 @@ protected void onStdin(byte[] chunk) throws IOException {
*/
stdin.write(chunk);
}
+
@Override
protected void onEndStdin() throws IOException {}
+
@Override
protected void handleClose() {}
+
void send() throws IOException {
- streamStdout().write("goodbye".getBytes());
+ streamStdout().write("goodbye".getBytes(Charset.defaultCharset()));
sendExit(2);
}
+
void newop() throws IOException {
DataOutputStream dos = new DataOutputStream(download);
dos.writeInt(0);
@@ -116,6 +135,7 @@ void newop() throws IOException {
dos.flush();
}
}
+
Client client = new Client();
Server server = new Server();
new PlainCLIProtocol.FramedReader(client, new PipedInputStream(download)).start();
@@ -137,9 +157,9 @@ void newop() throws IOException {
while (server.stdin.size() == 0) {
Thread.sleep(100);
}
- assertEquals("hello", server.stdin.toString());
+ assertEquals("hello", server.stdin.toString(Charset.defaultCharset().name()));
assertEquals("command", server.arg);
- assertEquals("goodbye", client.stdout.toString());
+ assertEquals("goodbye", client.stdout.toString(Charset.defaultCharset().name()));
assertEquals(2, client.code);
}
diff --git a/cli/src/test/java/hudson/cli/PrivateKeyProviderTest.java b/cli/src/test/java/hudson/cli/PrivateKeyProviderTest.java
index 9205c853f8ce2..8d960e87a4611 100644
--- a/cli/src/test/java/hudson/cli/PrivateKeyProviderTest.java
+++ b/cli/src/test/java/hudson/cli/PrivateKeyProviderTest.java
@@ -50,7 +50,7 @@ public void loadKeyDSAPassword() throws IOException, GeneralSecurityException {
String password = "password";
assertKeyPairNotNull(file, password);
}
-
+
/**
key command: ssh-keygen -f rsa -t rsa -b 1024 -m PEM
*/
@@ -69,7 +69,7 @@ public void loadKeyRSAPassword() throws IOException, GeneralSecurityException {
String password = "password";
assertKeyPairNotNull(file, password);
}
-
+
/**
key command: ssh-keygen -f openssh -t rsa -b 1024
*/
@@ -78,7 +78,7 @@ public void loadKeyOpenSSH() throws IOException, GeneralSecurityException {
File file = new File(this.getClass().getResource("openssh").getFile());
assertKeyPairNotNull(file, null);
}
-
+
/**
key command: ssh-keygen -f openssh-unsupported -t rsa -b 1024 -m PKCS8 -p password
*/
@@ -123,7 +123,7 @@ public void loadBlankKey() throws IOException, GeneralSecurityException {
/**
key command: ssh-keygen -f openssh -t rsa -b 1024
in this key we remove some lines to break the key.
- */
+ */
@Test
public void loadKeyBroken() throws IOException, GeneralSecurityException {
File file = new File(this.getClass().getResource("openssh-broken").getFile());
diff --git a/cli/src/test/java/hudson/util/QuotedStringTokenizerTest.java b/cli/src/test/java/hudson/util/QuotedStringTokenizerTest.java
index 9af792ca7b2fb..e5c546d11c3ee 100644
--- a/cli/src/test/java/hudson/util/QuotedStringTokenizerTest.java
+++ b/cli/src/test/java/hudson/util/QuotedStringTokenizerTest.java
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson.util;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
@@ -38,19 +39,19 @@ public class QuotedStringTokenizerTest {
@Test
public void test1() {
check("foo bar",
- "foo","bar");
+ "foo", "bar");
}
@Test
public void test2() {
check("foo \"bar zot\"",
- "foo","bar zot");
+ "foo", "bar zot");
}
@Test
public void test3() {
check("foo bar=\"quote zot\"",
- "foo","bar=quote zot");
+ "foo", "bar=quote zot");
}
@Test
@@ -68,7 +69,7 @@ public void test5() {
@Test
public void test6() {
check("foo\\\\ bar",
- "foo\\","bar");
+ "foo\\", "bar");
}
// see http://www.nabble.com/Error-parsing-%22-in-msbuild-task-to20535754.html
diff --git a/core/pom.xml b/core/pom.xml
index b85438f1c60bf..5e35d68b41875 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -41,7 +41,7 @@ THE SOFTWARE.
true
2.2
- 2.8.3
+ 2.9.0
@@ -56,34 +56,52 @@ THE SOFTWARE.
-
${project.groupId}
- remoting
+ cli
+ ${project.version}
${project.groupId}
- cli
- ${project.version}
+ remoting
- org.jenkins-ci
- version-number
+ antlr
+ antlr
- org.jenkins-ci
- crypto-util
+ args4j
+ args4j
-
-
- org.jenkins-ci
- core-annotation-processors
- 1.0
- provided
- true
+
+ com.github.spotbugs
+ spotbugs-annotations
+
+
+ com.google.code.findbugs
+ jsr305
+
+
+
+
+ com.google.guava
+ guava
+
+
+ com.google.errorprone
+ error_prone_annotations
+
+
+ com.google.j2objc
+ j2objc-annotations
+
+
+ org.checkerframework
+ checker-qual
+
+
-
com.google.inject
guice
@@ -95,232 +113,291 @@ THE SOFTWARE.
-
- org.connectbot.jbcrypt
- jbcrypt
+ com.infradna.tool
+ bridge-method-annotation
+ ${bridge-method-injector.version}
- com.github.jnr
- jnr-posix
+
+ com.jcraft
+ jzlib
- org.ow2.asm
- asm
+ com.sun.solaris
+ embedded_su4j
- org.ow2.asm
- asm-analysis
+ com.sun.xml.txw2
+ txw2
+
+
+
+ javax.xml.stream
+ stax-api
+
+
- org.ow2.asm
- asm-commons
+ com.thoughtworks.xstream
+ xstream
+
+
+ xmlpull
+ xmlpull
+
+
+ xpp3
+ xpp3_min
+
+
- org.ow2.asm
- asm-tree
+ commons-beanutils
+ commons-beanutils
- org.ow2.asm
- asm-util
+ commons-codec
+ commons-codec
- org.kohsuke.stapler
- stapler
-
-
- com.google.code.findbugs
- jsr305
-
-
+ commons-collections
+ commons-collections
- org.kohsuke.stapler
- stapler-groovy
+ commons-fileupload
+ commons-fileupload
+
+
+ commons-httpclient
+ commons-httpclient
+
+
+ commons-io
+ commons-io
+
+
+ commons-jelly
+ commons-jelly-tags-fmt
+
+
+ commons-jelly
+ commons-jelly-tags-xml
commons-jelly
commons-jelly
+
+ commons-jelly
+ commons-jelly-tags-junit
+
commons-jexl
commons-jexl
- org.jvnet.hudson
- commons-jexl
+ dom4j
+ dom4j
-
- org.codehaus.groovy
- groovy
+ xalan
+ xalan
+
+
+ xerces
+ xercesImpl
+
+
+ xml-apis
+ xml-apis
- org.kohsuke
- windows-package-checker
+
+ commons-lang
+ commons-lang
- org.kohsuke.stapler
- stapler-adjunct-timeline
+ io.jenkins.stapler
+ jenkins-stapler-support
- org.kohsuke.stapler
- stapler-adjunct-codemirror
+
+ jakarta.servlet.jsp.jstl
+ jakarta.servlet.jsp.jstl-api
-
- org.kohsuke.stapler
- stapler-adjunct-timeline
- 1.5
- tests
- test
+
+ jaxen
+ jaxen
+
+
+ dom4j
+ dom4j
+
+
+ jdom
+ jdom
+
+
+ xerces
+ xercesImpl
+
+
+ xml-apis
+ xml-apis
+
+
+ xom
+ xom
+
+
- io.jenkins.stapler
- jenkins-stapler-support
+
+ jline
+ jline
+ 2.14.6
+ compile
- org.hamcrest
- hamcrest
- ${hamcrest.version}
- test
+ net.java.dev.jna
+ jna
- org.hamcrest
- hamcrest-library
- ${hamcrest.version}
- test
+ net.java.sezpoz
+ sezpoz
-
- com.infradna.tool
- bridge-method-annotation
- ${bridge-method-injector.version}
+ net.jcip
+ jcip-annotations
-
-
- org.kohsuke.stapler
- json-lib
+
+ net.sf.kxml
+ kxml2
- commons-httpclient
- commons-httpclient
+ org.apache.ant
+ ant
- args4j
- args4j
+ org.apache.commons
+ commons-compress
+
+
+ org.codehaus.groovy
+ groovy-all
+
+
+ org.connectbot.jbcrypt
+ jbcrypt
+
+
+
+ org.fusesource.jansi
+ jansi
org.jenkins-ci
annotation-indexer
+
+ org.jenkins-ci
+ commons-jexl
+
+
+ org.jenkins-ci
+ crypto-util
+
+
+ org.jenkins-ci
+ memory-monitor
+
+
+ org.jenkins-ci
+ symbol-annotation
+
org.jenkins-ci
task-reactor
- org.jvnet.localizer
- localizer
+ org.jenkins-ci
+ version-number
- antlr
- antlr
+ org.jfree
+ jfreechart
- com.thoughtworks.xstream
- xstream
+ org.jvnet.hudson
+ commons-jelly-tags-define
- xmlpull
- xmlpull
+ commons-cli
+ commons-cli
- xpp3
- xpp3_min
+ dom4j
+ dom4j
+
+
+ org.jvnet.hudson
+ commons-jelly
-
- xpp3
- xpp3
- 1.1.4c
+ org.jvnet.localizer
+ localizer
- net.sf.kxml
- kxml2
+ org.jvnet.robust-http-client
+ robust-http-client
- org.jfree
- jfreechart
+ org.jvnet.winp
+ winp
- org.apache.ant
- ant
+ org.kohsuke
+ access-modifier-annotation
- javax.servlet
- javax.servlet-api
- 3.1.0
- provided
+ org.kohsuke
+ windows-package-checker
- commons-io
- commons-io
-
-
- commons-lang
- commons-lang
+ org.kohsuke.jinterop
+ j-interop
- commons-beanutils
- commons-beanutils
+
+ org.kohsuke.metainf-services
+ metainf-services
+ 1.8
+ true
- org.apache.commons
- commons-compress
+ org.kohsuke.stapler
+ json-lib
- com.sun.mail
- jakarta.mail
+ org.kohsuke.stapler
+ stapler
- jaxen
- jaxen
-
-
- dom4j
- dom4j
-
-
- xom
- xom
-
-
- xml-apis
- xml-apis
-
-
- xerces
- xercesImpl
-
-
- jdom
- jdom
-
-
+ org.kohsuke.stapler
+ stapler-adjunct-codemirror
- commons-jelly
- commons-jelly-tags-fmt
+ org.kohsuke.stapler
+ stapler-adjunct-timeline
- commons-jelly
- commons-jelly-tags-xml
+ org.kohsuke.stapler
+ stapler-groovy
commons-jelly
@@ -331,48 +408,43 @@ THE SOFTWARE.
commons-jexl
- commons-jelly
- commons-jelly-tags-junit
-
-
- xml-apis
- xml-apis
-
-
- xalan
- xalan
-
-
- xerces
- xercesImpl
+
+ org.codehaus.groovy
+ groovy
- dom4j
- dom4j
+ org.jvnet.hudson
+ commons-jexl
- org.jvnet.hudson
- commons-jelly-tags-define
-
-
- dom4j
- dom4j
-
-
- commons-cli
- commons-cli
-
-
- org.jvnet.hudson
- commons-jelly
-
-
+ org.ow2.asm
+ asm
- org.jenkins-ci
- commons-jexl
+ org.ow2.asm
+ asm-analysis
+
+
+ org.ow2.asm
+ asm-commons
+
+
+ org.ow2.asm
+ asm-tree
+
+
+ org.ow2.asm
+ asm-util
+
+
+ org.slf4j
+ jcl-over-slf4j
+
+
+ org.slf4j
+ log4j-over-slf4j
org.springframework.security
@@ -385,24 +457,59 @@ THE SOFTWARE.
- org.codehaus.groovy
- groovy-all
+
+ xpp3
+ xpp3
+ 1.1.4c
-
- jline
- jline
- 2.14.6
- compile
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+ provided
-
- org.fusesource.jansi
- jansi
+
+
+ org.jenkins-ci
+ core-annotation-processors
+ 1.0
+ provided
+ true
+
+
+
+
+ org.hamcrest
+ hamcrest
+ ${hamcrest.version}
+ test
+
+
+ org.hamcrest
+ hamcrest-library
+ ${hamcrest.version}
+ test
org.jenkins-ci
test-annotations
test
+
+ org.junit.jupiter
+ junit-jupiter
+ ${junit.jupiter.version}
+ test
+
org.junit.jupiter
junit-jupiter-api
@@ -422,9 +529,11 @@ THE SOFTWARE.
test
- org.junit.jupiter
- junit-jupiter
- ${junit.jupiter.version}
+
+ org.kohsuke.stapler
+ stapler-adjunct-timeline
+ 1.5
+ tests
test
@@ -433,135 +542,11 @@ THE SOFTWARE.
${mockito.version}
test
-
- jakarta.servlet.jsp.jstl
- jakarta.servlet.jsp.jstl-api
-
-
- org.slf4j
- jcl-over-slf4j
-
-
- org.slf4j
- log4j-over-slf4j
-
org.slf4j
slf4j-jdk14
test
-
- com.sun.xml.txw2
- txw2
-
-
-
- javax.xml.stream
- stax-api
-
-
-
-
- commons-collections
- commons-collections
-
-
- org.jvnet.winp
- winp
-
-
- org.jenkins-ci
- memory-monitor
-
-
- net.java.dev.jna
- jna
-
-
- com.sun.solaris
- embedded_su4j
-
-
- net.java.sezpoz
- sezpoz
-
-
- org.kohsuke.jinterop
- j-interop
-
-
- org.kohsuke.metainf-services
- metainf-services
- 1.8
- true
-
-
- org.jvnet.robust-http-client
- robust-http-client
-
-
- org.jenkins-ci
- symbol-annotation
-
-
-
- commons-codec
- commons-codec
-
-
-
- org.kohsuke
- access-modifier-annotation
-
-
-
- com.github.spotbugs
- spotbugs-annotations
- true
-
-
- net.jcip
- jcip-annotations
- true
-
-
-
- commons-fileupload
- commons-fileupload
-
-
-
-
-
-
- com.google.guava
- guava
-
-
- com.google.errorprone
- error_prone_annotations
-
-
- com.google.j2objc
- j2objc-annotations
-
-
- org.checkerframework
- checker-qual
-
-
-
-
-
- com.jcraft
- jzlib
-
org.xmlunit
xmlunit-core
@@ -585,10 +570,10 @@ THE SOFTWARE.
add-source
- generate-sources
add-source
+ generate-sources
@@ -641,7 +626,8 @@ THE SOFTWARE.
maven-stapler-plugin
- ${staplerFork}
+
+ ${staplerFork}
128m
@@ -706,11 +692,11 @@ THE SOFTWARE.
winsw
- generate-resources
copy
+ generate-resources
@@ -735,7 +721,8 @@ THE SOFTWARE.
false
-
+
+
maven-jar-plugin
@@ -753,7 +740,8 @@ THE SOFTWARE.
-
+
+
org.kohsuke.stapler
maven-stapler-plugin
@@ -763,7 +751,8 @@ THE SOFTWARE.
-
+
+
maven-project-info-reports-plugin
@@ -830,37 +819,17 @@ THE SOFTWARE.
- japicmp
+ jdk-9-and-above
+
+ [9,)
+
- com.github.siom79.japicmp
- japicmp-maven-plugin
- 0.14.4-20200728.214757-1
+ maven-surefire-plugin
-
-
- \d+[.]\d+
-
- true
-
-
-
- javax.servlet
- javax.servlet-api
- 3.1.0
- provided
-
-
+ --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED
-
-
- verify
-
- cmp
-
-
-
diff --git a/core/src/main/java/hudson/AbortException.java b/core/src/main/java/hudson/AbortException.java
index b68276e8eec12..d3d58122c87ee 100644
--- a/core/src/main/java/hudson/AbortException.java
+++ b/core/src/main/java/hudson/AbortException.java
@@ -1,18 +1,18 @@
/*
* The MIT License
- *
+ *
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson;
import java.io.IOException;
diff --git a/core/src/main/java/hudson/AboutJenkins.java b/core/src/main/java/hudson/AboutJenkins.java
index c94bbb48f7c36..8f355b21b0308 100644
--- a/core/src/main/java/hudson/AboutJenkins.java
+++ b/core/src/main/java/hudson/AboutJenkins.java
@@ -14,14 +14,14 @@
/**
* Show "About Jenkins" link.
- *
+ *
* @author Kohsuke Kawaguchi
*/
@Extension @Symbol("about")
public class AboutJenkins extends ManagementLink {
@Override
public String getIconFileName() {
- return "help.png";
+ return "symbol-jenkins";
}
@Override
diff --git a/core/src/main/java/hudson/AbstractMarkupText.java b/core/src/main/java/hudson/AbstractMarkupText.java
index 59e65e9bcba02..b13eeaad3edd0 100644
--- a/core/src/main/java/hudson/AbstractMarkupText.java
+++ b/core/src/main/java/hudson/AbstractMarkupText.java
@@ -1,18 +1,18 @@
/*
* The MIT License
- *
+ *
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson;
import hudson.MarkupText.SubText;
@@ -74,15 +75,15 @@ public final int length() {
* For example, if the text was "abc", then {@code addMarkup(1,2,"","")}
* would generate {@code "abc"}
*/
- public abstract void addMarkup( int startPos, int endPos, String startTag, String endTag );
+ public abstract void addMarkup(int startPos, int endPos, String startTag, String endTag);
/**
* Inserts an A tag that surrounds the given position.
*
* @since 1.349
*/
- public void addHyperlink( int startPos, int endPos, String url ) {
- addMarkup(startPos,endPos,"","");
+ public void addHyperlink(int startPos, int endPos, String url) {
+ addMarkup(startPos, endPos, "", "");
}
/**
@@ -91,22 +92,22 @@ public void addHyperlink( int startPos, int endPos, String url ) {
*
* @since 1.395
*/
- public void addHyperlinkLowKey( int startPos, int endPos, String url ) {
- addMarkup(startPos,endPos,"","");
+ public void addHyperlinkLowKey(int startPos, int endPos, String url) {
+ addMarkup(startPos, endPos, "", "");
}
/**
* Hides the given text.
*/
- public void hide( int startPos, int endPos ) {
- addMarkup(startPos,endPos,"","");
+ public void hide(int startPos, int endPos) {
+ addMarkup(startPos, endPos, "", "");
}
/**
* Adds a start tag and end tag around the entire text
*/
public final void wrapBy(String startTag, String endTag) {
- addMarkup(0,length(),startTag,endTag);
+ addMarkup(0, length(), startTag, endTag);
}
/**
@@ -118,7 +119,7 @@ public MarkupText.SubText findToken(Pattern pattern) {
String text = getText();
Matcher m = pattern.matcher(text);
- if(m.find())
+ if (m.find())
return createSubText(m);
return null;
@@ -142,17 +143,17 @@ public List findTokens(Pattern pattern) {
Matcher m = pattern.matcher(text);
List r = new ArrayList<>();
- while(m.find()) {
+ while (m.find()) {
int idx = m.start();
- if(idx>0) {
- char ch = text.charAt(idx-1);
- if(Character.isLetter(ch) || Character.isDigit(ch))
+ if (idx > 0) {
+ char ch = text.charAt(idx - 1);
+ if (Character.isLetter(ch) || Character.isDigit(ch))
continue; // not at a word boundary
}
idx = m.end();
- if(idx optionalDependencies) {
String pluginName = atts.getValue("Short-Name");
-
+
String jenkinsVersion = atts.getValue("Jenkins-Version");
- if (jenkinsVersion==null)
+ if (jenkinsVersion == null)
jenkinsVersion = atts.getValue("Hudson-Version");
for (Dependency d : DetachedPluginsUtil.getImpliedDependencies(pluginName, jenkinsVersion)) {
@@ -278,7 +279,7 @@ public static List getImpliedDependencies(String plugi
@Deprecated
protected ClassLoader createClassLoader(List paths, ClassLoader parent) throws IOException {
- return createClassLoader( paths, parent, null );
+ return createClassLoader(paths, parent, null);
}
/**
@@ -322,7 +323,7 @@ protected ClassLoader createClassLoader(List paths, ClassLoader parent, At
*/
private ClassLoader getBaseClassLoader(Attributes atts, ClassLoader base) {
String masked = atts.getValue("Mask-Classes");
- if(masked!=null)
+ if (masked != null)
base = new MaskingClassLoader(base, masked.trim().split("[ \t\r\n]+"));
return base;
}
@@ -335,7 +336,7 @@ public void initializeComponents(PluginWrapper plugin) {
public List> findComponents(Class type, Hudson hudson) {
List finders;
- if (type==ExtensionFinder.class) {
+ if (type == ExtensionFinder.class) {
// Avoid infinite recursion of using ExtensionFinders to find ExtensionFinders
finders = Collections.singletonList(new ExtensionFinder.Sezpoz());
} else {
@@ -346,7 +347,7 @@ public List> findComponents(Class type, Hudson huds
* See ExtensionFinder#scout(Class, Hudson) for the dead lock issue and what this does.
*/
if (LOGGER.isLoggable(Level.FINER))
- LOGGER.log(Level.FINER, "Scout-loading ExtensionList: "+type, new Throwable());
+ LOGGER.log(Level.FINER, "Scout-loading ExtensionList: " + type, new Throwable());
for (ExtensionFinder finder : finders) {
finder.scout(type, hudson);
}
@@ -364,7 +365,7 @@ public List> findComponents(Class type, Hudson huds
List> filtered = new ArrayList<>();
for (ExtensionComponent e : r) {
- if (ExtensionFilter.isAllowed(type,e))
+ if (ExtensionFilter.isAllowed(type, e))
filtered.add(e);
}
@@ -379,21 +380,21 @@ public void load(PluginWrapper wrapper) throws IOException {
Thread.currentThread().setContextClassLoader(wrapper.classLoader);
try {
String className = wrapper.getPluginClass();
- if(className==null) {
+ if (className == null) {
// use the default dummy instance
wrapper.setPlugin(new DummyImpl());
} else {
try {
Class> clazz = wrapper.classLoader.loadClass(className);
Object o = clazz.getDeclaredConstructor().newInstance();
- if(!(o instanceof Plugin)) {
- throw new IOException(className+" doesn't extend from hudson.Plugin");
+ if (!(o instanceof Plugin)) {
+ throw new IOException(className + " doesn't extend from hudson.Plugin");
}
wrapper.setPlugin((Plugin) o);
} catch (LinkageError | ClassNotFoundException e) {
- throw new IOException("Unable to load " + className + " from " + wrapper.getShortName(),e);
+ throw new IOException("Unable to load " + className + " from " + wrapper.getShortName(), e);
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
- throw new IOException("Unable to create instance of " + className + " from " + wrapper.getShortName(),e);
+ throw new IOException("Unable to create instance of " + className + " from " + wrapper.getShortName(), e);
}
}
@@ -402,9 +403,9 @@ public void load(PluginWrapper wrapper) throws IOException {
Plugin plugin = wrapper.getPluginOrFail();
plugin.setServletContext(pluginManager.context);
startPlugin(wrapper);
- } catch(Throwable t) {
+ } catch (Throwable t) {
// gracefully handle any error in plugin.
- throw new IOException("Failed to initialize",t);
+ throw new IOException("Failed to initialize", t);
}
} finally {
Thread.currentThread().setContextClassLoader(old);
@@ -428,14 +429,14 @@ private DependencyClassLoader findAncestorDependencyClassLoader(ClassLoader clas
{
for (; classLoader != null; classLoader = classLoader.getParent()) {
if (classLoader instanceof DependencyClassLoader) {
- return (DependencyClassLoader)classLoader;
+ return (DependencyClassLoader) classLoader;
}
-
+
if (classLoader instanceof AntClassLoader) {
// AntClassLoaders hold parents not only as AntClassLoader#getParent()
// but also as AntClassLoader#getConfiguredParent()
DependencyClassLoader ret = findAncestorDependencyClassLoader(
- ((AntClassLoader)classLoader).getConfiguredParent()
+ ((AntClassLoader) classLoader).getConfiguredParent()
);
if (ret != null) {
return ret;
@@ -448,29 +449,29 @@ private DependencyClassLoader findAncestorDependencyClassLoader(ClassLoader clas
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "Administrator action installing a plugin, which could do far worse.")
private static File resolve(File base, String relative) {
File rel = new File(relative);
- if(rel.isAbsolute())
+ if (rel.isAbsolute())
return rel;
else
- return new File(base.getParentFile(),relative);
+ return new File(base.getParentFile(), relative);
}
private static void parseClassPath(Manifest manifest, File archive, List paths, String attributeName, String separator) throws IOException {
String classPath = manifest.getMainAttributes().getValue(attributeName);
- if(classPath==null) return; // attribute not found
+ if (classPath == null) return; // attribute not found
for (String s : classPath.split(separator)) {
File file = resolve(archive, s);
- if(file.getName().contains("*")) {
+ if (file.getName().contains("*")) {
// handle wildcard
FileSet fs = new FileSet();
File dir = file.getParentFile();
fs.setDir(dir);
fs.setIncludes(file.getName());
- for( String included : fs.getDirectoryScanner(new Project()).getIncludedFiles() ) {
- paths.add(new File(dir,included));
+ for (String included : fs.getDirectoryScanner(new Project()).getIncludedFiles()) {
+ paths.add(new File(dir, included));
}
} else {
- if(!file.exists())
- throw new IOException("No such file: "+file);
+ if (!file.exists())
+ throw new IOException("No such file: " + file);
paths.add(file);
}
}
@@ -480,11 +481,11 @@ private static void parseClassPath(Manifest manifest, File archive, List p
* Explodes the plugin into a directory, if necessary.
*/
private static void explode(File archive, File destDir) throws IOException {
- Files.createDirectories(Util.fileToPath(destDir));
+ Util.createDirectories(Util.fileToPath(destDir));
// timestamp check
- File explodeTime = new File(destDir,".timestamp2");
- if(explodeTime.exists() && explodeTime.lastModified()==archive.lastModified())
+ File explodeTime = new File(destDir, ".timestamp2");
+ if (explodeTime.exists() && explodeTime.lastModified() == archive.lastModified())
return; // no need to expand
// delete the contents so that old files won't interfere with new files
@@ -495,7 +496,7 @@ private static void explode(File archive, File destDir) throws IOException {
unzipExceptClasses(archive, destDir, prj);
createClassJarFromWebInfClasses(archive, destDir, prj);
} catch (BuildException x) {
- throw new IOException("Failed to expand " + archive,x);
+ throw new IOException("Failed to expand " + archive, x);
}
try {
@@ -530,7 +531,7 @@ private static void createClassJarFromWebInfClasses(File archive, File destDir,
try (ZipOutputStream wrappedZOut = new ZipOutputStream(NullOutputStream.NULL_OUTPUT_STREAM) {
@Override
public void putNextEntry(ZipEntry ze) throws IOException {
- ze.setTime(dirTime+1999); // roundup
+ ze.setTime(dirTime + 1999); // roundup
super.putNextEntry(ze);
}
}) {
@@ -544,12 +545,12 @@ protected void zipDir(Resource dir, ZipOutputStream zOut, String vPath,
int mode, ZipExtraField[] extra)
throws IOException {
// use wrappedZOut instead of zOut
- super.zipDir(dir,wrappedZOut,vPath,mode,extra);
+ super.zipDir(dir, wrappedZOut, vPath, mode, extra);
}
};
z.setProject(prj);
z.setTaskType("zip");
- Files.createDirectories(Util.fileToPath(classesJar.getParentFile()));
+ Util.createDirectories(Util.fileToPath(classesJar.getParentFile()));
z.setDestFile(classesJar);
z.add(mapper);
z.execute();
@@ -617,7 +618,7 @@ protected List getEdges(PluginWrapper pw) {
List dep = new ArrayList<>();
for (Dependency d : pw.getDependencies()) {
PluginWrapper p = pluginManager.getPlugin(d.shortName);
- if (p!=null && p.isActive())
+ if (p != null && p.isActive())
dep.add(p);
}
return dep;
@@ -627,7 +628,7 @@ protected List getEdges(PluginWrapper pw) {
try {
for (Dependency d : dependencies) {
PluginWrapper p = pluginManager.getPlugin(d.shortName);
- if (p!=null && p.isActive())
+ if (p != null && p.isActive())
cgd.run(Collections.singleton(p));
}
} catch (CycleDetectedException e) {
@@ -654,7 +655,7 @@ protected Class> findClass(String name) throws ClassNotFoundException {
} else {
for (Dependency dep : dependencies) {
PluginWrapper p = pluginManager.getPlugin(dep.shortName);
- if(p!=null) {
+ if (p != null) {
try {
return p.classLoader.loadClass(name);
} catch (ClassNotFoundException ignored) {
@@ -682,7 +683,7 @@ protected Enumeration findResources(String name) throws IOException {
} else {
for (Dependency dep : dependencies) {
PluginWrapper p = pluginManager.getPlugin(dep.shortName);
- if (p!=null) {
+ if (p != null) {
Enumeration urls = p.classLoader.getResources(name);
while (urls != null && urls.hasMoreElements())
result.add(urls.nextElement());
@@ -698,14 +699,14 @@ protected URL findResource(String name) {
if (PluginManager.FAST_LOOKUP) {
for (PluginWrapper pw : getTransitiveDependencies()) {
URL url = ClassLoaderReflectionToolkit._findResource(pw.classLoader, name);
- if (url!=null) return url;
+ if (url != null) return url;
}
} else {
for (Dependency dep : dependencies) {
PluginWrapper p = pluginManager.getPlugin(dep.shortName);
- if(p!=null) {
+ if (p != null) {
URL url = p.classLoader.getResource(name);
- if (url!=null)
+ if (url != null)
return url;
}
}
diff --git a/core/src/main/java/hudson/CloseProofOutputStream.java b/core/src/main/java/hudson/CloseProofOutputStream.java
index 5a9090e79cc40..0fc4aee48a5ce 100644
--- a/core/src/main/java/hudson/CloseProofOutputStream.java
+++ b/core/src/main/java/hudson/CloseProofOutputStream.java
@@ -1,18 +1,18 @@
/*
* The MIT License
- *
+ *
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson;
import hudson.util.DelegatingOutputStream;
diff --git a/core/src/main/java/hudson/CopyOnWrite.java b/core/src/main/java/hudson/CopyOnWrite.java
index ff6bc92d57565..04e737964a801 100644
--- a/core/src/main/java/hudson/CopyOnWrite.java
+++ b/core/src/main/java/hudson/CopyOnWrite.java
@@ -1,18 +1,18 @@
/*
* The MIT License
- *
+ *
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson;
import static java.lang.annotation.ElementType.FIELD;
diff --git a/core/src/main/java/hudson/DependencyRunner.java b/core/src/main/java/hudson/DependencyRunner.java
index 914be79ffa6f7..b7db91fb94164 100644
--- a/core/src/main/java/hudson/DependencyRunner.java
+++ b/core/src/main/java/hudson/DependencyRunner.java
@@ -1,19 +1,19 @@
/*
* The MIT License
- *
+ *
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi,
* Brian Westrich, Jean-Baptiste Quenot
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson;
import hudson.model.AbstractProject;
@@ -41,7 +42,7 @@
public class DependencyRunner implements Runnable {
private static final Logger LOGGER = Logger.getLogger(DependencyRunner.class.getName());
-
+
ProjectRunnable runnable;
List polledProjects = new ArrayList<>();
@@ -72,11 +73,11 @@ public void run() {
}
private void populate(Collection extends AbstractProject> projectList) {
- for (AbstractProject,?> p : projectList) {
+ for (AbstractProject, ?> p : projectList) {
if (polledProjects.contains(p)) {
// Project will be readded at the queue, so that we always use
// the longest path
- LOGGER.fine("removing project " + p.getName() + " for re-add");
+ LOGGER.fine("removing project " + p.getName() + " for re-add");
polledProjects.remove(p);
}
diff --git a/core/src/main/java/hudson/DescriptorExtensionList.java b/core/src/main/java/hudson/DescriptorExtensionList.java
index 25f1191706509..7c9fbbddccacc 100644
--- a/core/src/main/java/hudson/DescriptorExtensionList.java
+++ b/core/src/main/java/hudson/DescriptorExtensionList.java
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson;
import edu.umd.cs.findbugs.annotations.CheckForNull;
@@ -71,8 +72,8 @@ public class DescriptorExtensionList, D extends Descrip
* Creates a new instance.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
- public static ,D extends Descriptor>
- DescriptorExtensionList createDescriptorList(Jenkins jenkins, Class describableType) {
+ public static , D extends Descriptor>
+ DescriptorExtensionList createDescriptorList(Jenkins jenkins, Class describableType) {
if (describableType == Publisher.class) {
return (DescriptorExtensionList) new Publisher.DescriptorExtensionListImpl(jenkins);
}
@@ -84,9 +85,9 @@ DescriptorExtensionList createDescriptorList(Jenkins jenkins, Class desc
* Use {@link #create(Jenkins, Class)}
*/
@Deprecated
- public static ,D extends Descriptor>
- DescriptorExtensionList createDescriptorList(Hudson hudson, Class describableType) {
- return (DescriptorExtensionList)createDescriptorList((Jenkins)hudson,describableType);
+ public static , D extends Descriptor>
+ DescriptorExtensionList createDescriptorList(Hudson hudson, Class describableType) {
+ return (DescriptorExtensionList) createDescriptorList((Jenkins) hudson, describableType);
}
/**
@@ -100,11 +101,11 @@ DescriptorExtensionList createDescriptorList(Hudson hudson, Class descri
*/
@Deprecated
protected DescriptorExtensionList(Hudson hudson, Class describableType) {
- this((Jenkins)hudson,describableType);
+ this((Jenkins) hudson, describableType);
}
protected DescriptorExtensionList(Jenkins jenkins, Class describableType) {
- super(jenkins, (Class)Descriptor.class, (CopyOnWriteArrayList)getLegacyDescriptors(describableType));
+ super(jenkins, (Class) Descriptor.class, (CopyOnWriteArrayList) getLegacyDescriptors(describableType));
this.describableType = describableType;
}
@@ -117,7 +118,7 @@ protected DescriptorExtensionList(Jenkins jenkins, Class describableType) {
*/
@Deprecated
public D find(String fqcn) {
- return Descriptor.find(this,fqcn);
+ return Descriptor.find(this, fqcn);
}
/**
@@ -126,7 +127,7 @@ public D find(String fqcn) {
*/
public D find(Class extends T> type) {
for (D d : this)
- if (d.clazz==type)
+ if (d.clazz == type)
return d;
return null;
}
@@ -141,10 +142,10 @@ public D find(Class extends T> type) {
*/
@CheckForNull
public T newInstanceFromRadioList(JSONObject config) throws FormException {
- if(config.isNullObject())
+ if (config.isNullObject())
return null; // none was selected
int idx = config.getInt("value");
- return get(idx).newInstance(Stapler.getCurrentRequest(),config);
+ return get(idx).newInstance(Stapler.getCurrentRequest(), config);
}
/**
@@ -171,7 +172,7 @@ public T newInstanceFromRadioList(@NonNull JSONObject parent, @NonNull String na
*/
public @CheckForNull D findByName(String id) {
for (D d : this)
- if(d.getId().equals(id))
+ if (d.getId().equals(id))
return d;
return null;
}
@@ -219,11 +220,11 @@ protected Collection> load(ExtensionComponentSet delta) {
private List> _load(Iterable> set) {
List> r = new ArrayList<>();
- for( ExtensionComponent c : set ) {
+ for (ExtensionComponent c : set) {
Descriptor d = c.getInstance();
try {
- if(d.getT()==describableType)
- r.add((ExtensionComponent)c);
+ if (d.getT() == describableType)
+ r.add((ExtensionComponent) c);
} catch (IllegalStateException e) {
LOGGER.log(Level.SEVERE, d.getClass() + " doesn't extend Descriptor with a type parameter", e); // skip this one
}
@@ -253,8 +254,8 @@ public static Iterable listLegacyInstances() {
return new Iterable() {
@Override
public Iterator iterator() {
- return new AdaptedIterator,Descriptor>(
- new FlattenIterator,CopyOnWriteArrayList>>(legacyDescriptors.values()) {
+ return new AdaptedIterator, Descriptor>(
+ new FlattenIterator, CopyOnWriteArrayList>>(legacyDescriptors.values()) {
@Override
protected Iterator> expand(CopyOnWriteArrayList> v) {
return v.iterator();
diff --git a/core/src/main/java/hudson/EnvVars.java b/core/src/main/java/hudson/EnvVars.java
index 673396061a6c3..cce69ede9ee84 100644
--- a/core/src/main/java/hudson/EnvVars.java
+++ b/core/src/main/java/hudson/EnvVars.java
@@ -1,18 +1,18 @@
/*
* The MIT License
- *
+ *
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Red Hat, Inc.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson;
import edu.umd.cs.findbugs.annotations.CheckForNull;
@@ -71,7 +72,7 @@
*
* @author Kohsuke Kawaguchi
*/
-public class EnvVars extends TreeMap {
+public class EnvVars extends TreeMap {
private static final long serialVersionUID = 4320331661987259022L;
private static Logger LOGGER = Logger.getLogger(EnvVars.class.getName());
/**
@@ -84,7 +85,7 @@ public class EnvVars extends TreeMap {
* So this property remembers that information.
*/
private Platform platform;
-
+
/**
* Gets the platform for which these env vars targeted.
* @since 2.144
@@ -102,11 +103,12 @@ public class EnvVars extends TreeMap {
public void setPlatform(@NonNull Platform platform) {
this.platform = platform;
}
+
public EnvVars() {
super(String.CASE_INSENSITIVE_ORDER);
}
- public EnvVars(@NonNull Map m) {
+ public EnvVars(@NonNull Map m) {
this();
putAll(m);
@@ -121,7 +123,7 @@ public EnvVars(@NonNull Map m) {
@SuppressWarnings("CopyConstructorMissesField") // does not set #platform, see its Javadoc
public EnvVars(@NonNull EnvVars m) {
// this constructor is so that in future we can get rid of the downcasting.
- this((Map)m);
+ this((Map) m);
}
/**
@@ -129,10 +131,10 @@ public EnvVars(@NonNull EnvVars m) {
*/
public EnvVars(String... keyValuePairs) {
this();
- if(keyValuePairs.length%2!=0)
+ if (keyValuePairs.length % 2 != 0)
throw new IllegalArgumentException(Arrays.asList(keyValuePairs).toString());
- for( int i=0; i0) {
- String realKey = key.substring(0,idx);
+ if (idx > 0) {
+ String realKey = key.substring(0, idx);
String v = get(realKey);
- if(v==null) v=value;
+ if (v == null) v = value;
else {
// we might be handling environment variables for a agent that can have different path separator
// than the controller, so the following is an attempt to get it right.
// it's still more error prone that I'd like.
- char ch = platform==null ? File.pathSeparatorChar : platform.pathSeparator;
- v=value+ch+v;
+ char ch = platform == null ? File.pathSeparatorChar : platform.pathSeparator;
+ v = value + ch + v;
}
- put(realKey,v);
+ put(realKey, v);
return;
}
- put(key,value);
+ put(key, value);
}
/**
@@ -171,18 +173,18 @@ public void override(String key, String value) {
* See {@link #override(String, String)}.
* @return this
*/
- public EnvVars overrideAll(Map all) {
+ public EnvVars overrideAll(Map all) {
for (Map.Entry e : all.entrySet()) {
- override(e.getKey(),e.getValue());
+ override(e.getKey(), e.getValue());
}
return this;
}
/**
* Calculates the order to override variables.
- *
+ *
* Sort variables with topological sort with their reference graph.
- *
+ *
* This is package accessible for testing purpose.
*/
static class OverrideOrderCalculator {
@@ -192,31 +194,31 @@ static class OverrideOrderCalculator {
private static class TraceResolver implements VariableResolver {
private final Comparator super String> comparator;
public Set referredVariables;
-
+
TraceResolver(Comparator super String> comparator) {
this.comparator = comparator;
clear();
}
-
+
public void clear() {
referredVariables = new TreeSet<>(comparator);
}
-
+
@Override
public String resolve(String name) {
referredVariables.add(name);
return "";
}
}
-
+
private static class VariableReferenceSorter extends CyclicGraphDetector {
// map from a variable to a set of variables that variable refers.
private final Map> refereeSetMap;
-
+
VariableReferenceSorter(Map> refereeSetMap) {
this.refereeSetMap = refereeSetMap;
}
-
+
@Override
protected Iterable extends String> getEdges(String n) {
// return variables referred from the variable.
@@ -229,32 +231,32 @@ protected Iterable extends String> getEdges(String n) {
}
private final Comparator super String> comparator;
-
+
@NonNull
private final EnvVars target;
@NonNull
- private final Map overrides;
-
+ private final Map overrides;
+
private Map> refereeSetMap;
private List orderedVariableNames;
-
- OverrideOrderCalculator(@NonNull EnvVars target, @NonNull Map overrides) {
+
+ OverrideOrderCalculator(@NonNull EnvVars target, @NonNull Map overrides) {
comparator = target.comparator();
this.target = target;
this.overrides = overrides;
scan();
}
-
+
public List getOrderedVariableNames() {
return orderedVariableNames;
}
-
+
// Cut the reference to the variable in a cycle.
private void cutCycleAt(String referee, List cycle) {
// cycle contains variables in referrer-to-referee order.
// This should not be negative, for the first and last one is same.
int refererIndex = cycle.lastIndexOf(referee) - 1;
-
+
assert refererIndex >= 0;
String referrer = cycle.get(refererIndex);
boolean removed = refereeSetMap.get(referrer).remove(referee);
@@ -262,7 +264,7 @@ private void cutCycleAt(String referee, List cycle) {
LOGGER.warning(String.format("Cyclic reference detected: %s", String.join(" -> ", cycle)));
LOGGER.warning(String.format("Cut the reference %s -> %s", referrer, referee));
}
-
+
// Cut the variable reference in a cycle.
private void cutCycle(List cycle) {
// if an existing variable is contained in that cycle,
@@ -273,27 +275,27 @@ private void cutCycle(List cycle) {
// PATH1=/usr/local/bin:${PATH}
// PATH=/opt/something/bin:${PATH1}
// then consider reference PATH1 -> PATH can be ignored.
- for (String referee: cycle) {
+ for (String referee : cycle) {
if (target.containsKey(referee)) {
cutCycleAt(referee, cycle);
return;
}
}
-
+
// if not, cut the reference to the first one.
cutCycleAt(cycle.get(0), cycle);
}
-
+
/**
* Scan all variables and list all referring variables.
*/
public void scan() {
refereeSetMap = new TreeMap<>(comparator);
List extendingVariableNames = new ArrayList<>();
-
+
TraceResolver resolver = new TraceResolver(comparator);
-
- for (Map.Entry entry: overrides.entrySet()) {
+
+ for (Map.Entry entry : overrides.entrySet()) {
if (entry.getKey().indexOf('+') > 0) {
// XYZ+AAA variables should be always processed in last.
extendingVariableNames.add(entry.getKey());
@@ -301,20 +303,20 @@ public void scan() {
}
resolver.clear();
Util.replaceMacro(entry.getValue(), resolver);
-
+
// Variables directly referred from the current scanning variable.
Set refereeSet = resolver.referredVariables;
// Ignore self reference.
refereeSet.remove(entry.getKey());
refereeSetMap.put(entry.getKey(), refereeSet);
}
-
+
VariableReferenceSorter sorter;
- while(true) {
+ while (true) {
sorter = new VariableReferenceSorter(refereeSetMap);
try {
sorter.run(refereeSetMap.keySet());
- } catch(CycleDetectedException e) {
+ } catch (CycleDetectedException e) {
// cyclic reference found.
// cut the cycle and retry.
@SuppressWarnings("unchecked")
@@ -324,15 +326,15 @@ public void scan() {
}
break;
}
-
+
// When A refers B, the last appearance of B always comes after
// the last appearance of A.
List reversedDuplicatedOrder = new ArrayList<>(sorter.getSorted());
Collections.reverse(reversedDuplicatedOrder);
-
+
orderedVariableNames = new ArrayList<>(overrides.size());
- for(String key: reversedDuplicatedOrder) {
- if(overrides.containsKey(key) && !orderedVariableNames.contains(key)) {
+ for (String key : reversedDuplicatedOrder) {
+ if (overrides.containsKey(key) && !orderedVariableNames.contains(key)) {
orderedVariableNames.add(key);
}
}
@@ -340,14 +342,14 @@ public void scan() {
orderedVariableNames.addAll(extendingVariableNames);
}
}
-
+
/**
* Overrides all values in the map by the given map. Expressions in values will be expanded.
* See {@link #override(String, String)}.
* @return {@code this}
*/
- public EnvVars overrideExpandingAll(@NonNull Map all) {
+ public EnvVars overrideExpandingAll(@NonNull Map all) {
for (String key : new OverrideOrderCalculator(this, all).getOrderedVariableNames()) {
override(key, expand(all.get(key)));
}
@@ -357,11 +359,11 @@ public EnvVars overrideExpandingAll(@NonNull Map all) {
/**
* Resolves environment variables against each other.
*/
- public static void resolve(Map env) {
- for (Map.Entry entry: env.entrySet()) {
- entry.setValue(Util.replaceMacro(entry.getValue(), env));
- }
- }
+ public static void resolve(Map env) {
+ for (Map.Entry entry : env.entrySet()) {
+ entry.setValue(Util.replaceMacro(entry.getValue(), env));
+ }
+ }
/**
* Convenience message
@@ -369,14 +371,14 @@ public static void resolve(Map env) {
**/
public String get(String key, String defaultValue) {
String v = get(key);
- if (v==null) v=defaultValue;
+ if (v == null) v = defaultValue;
return v;
}
@Override
public String put(String key, String value) {
- if (value==null) throw new IllegalArgumentException("Null value not allowed as an environment variable: "+key);
- return super.put(key,value);
+ if (value == null) throw new IllegalArgumentException("Null value not allowed as an environment variable: " + key);
+ return super.put(key, value);
}
/**
@@ -384,8 +386,8 @@ public String put(String key, String value) {
* @since 1.556
*/
public void putIfNotNull(String key, String value) {
- if (value!=null)
- put(key,value);
+ if (value != null)
+ put(key, value);
}
/**
@@ -396,14 +398,14 @@ public void putAllNonNull(Map map) {
map.forEach(this::putIfNotNull);
}
-
+
/**
* Takes a string that looks like "a=b" and adds that to this map.
*/
public void addLine(String line) {
int sep = line.indexOf('=');
- if(sep > 0) {
- put(line.substring(0,sep),line.substring(sep+1));
+ if (sep > 0) {
+ put(line.substring(0, sep), line.substring(sep + 1));
}
}
@@ -431,16 +433,17 @@ public static EnvVars createCookie() {
* A fresh copy that can be owned and modified by the caller.
*/
public static EnvVars getRemote(VirtualChannel channel) throws IOException, InterruptedException {
- if(channel==null)
- return new EnvVars("N/A","N/A");
+ if (channel == null)
+ return new EnvVars("N/A", "N/A");
return channel.call(new GetEnvVars());
}
- private static final class GetEnvVars extends MasterToSlaveCallable {
+ private static final class GetEnvVars extends MasterToSlaveCallable {
@Override
public EnvVars call() {
return new EnvVars(EnvVars.masterEnvVars);
}
+
private static final long serialVersionUID = 1L;
}
@@ -456,12 +459,12 @@ public EnvVars call() {
* If you access this field from agents, then this is the environment
* variable of the agent.
*/
- public static final Map masterEnvVars = initMaster();
+ public static final Map masterEnvVars = initMaster();
private static EnvVars initMaster() {
EnvVars vars = new EnvVars(System.getenv());
vars.platform = Platform.current();
- if(Main.isUnitTest || Main.isDevelopmentMode)
+ if (Main.isUnitTest || Main.isDevelopmentMode)
// if unit test is launched with maven debug switch,
// we need to prevent forked Maven processes from seeing it, or else
// they'll hang
diff --git a/core/src/main/java/hudson/ExpressionFactory2.java b/core/src/main/java/hudson/ExpressionFactory2.java
index e71202f4552b1..7fcec22e76047 100644
--- a/core/src/main/java/hudson/ExpressionFactory2.java
+++ b/core/src/main/java/hudson/ExpressionFactory2.java
@@ -72,14 +72,14 @@ public String getExpressionText() {
public Object evaluate(JellyContext context) {
try {
CURRENT_CONTEXT.set(context);
- JexlContext jexlContext = new JellyJexlContext( context );
+ JexlContext jexlContext = new JellyJexlContext(context);
return expression.evaluate(jexlContext);
} catch (AccessDeniedException e) {
// let the security exception pass through
throw e;
} catch (Exception e) {
StaplerRequest currentRequest = Stapler.getCurrentRequest();
- LOGGER.log(Level.WARNING,"Caught exception evaluating: " + expression + " in " + (currentRequest != null ? currentRequest.getOriginalRequestURI() : "?") + ". Reason: " + e, e);
+ LOGGER.log(Level.WARNING, "Caught exception evaluating: " + expression + " in " + (currentRequest != null ? currentRequest.getOriginalRequestURI() : "?") + ". Reason: " + e, e);
return null;
} finally {
CURRENT_CONTEXT.set(null);
@@ -93,13 +93,13 @@ static final class JellyJexlContext implements JexlContext {
private Map vars;
JellyJexlContext(JellyContext context) {
- this.vars = new JellyMap( context );
+ this.vars = new JellyMap(context);
}
@Override
public void setVars(Map vars) {
this.vars.clear();
- this.vars.putAll( vars );
+ this.vars.putAll(vars);
}
@Override
@@ -119,7 +119,7 @@ static final class JellyMap implements Map {
@Override
public Object get(Object key) {
- return context.getVariable( (String) key );
+ return context.getVariable((String) key);
}
@Override
diff --git a/core/src/main/java/hudson/Extension.java b/core/src/main/java/hudson/Extension.java
index 0bcffcefbe294..b240e37f87db1 100644
--- a/core/src/main/java/hudson/Extension.java
+++ b/core/src/main/java/hudson/Extension.java
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson;
import static java.lang.annotation.ElementType.FIELD;
diff --git a/core/src/main/java/hudson/ExtensionComponent.java b/core/src/main/java/hudson/ExtensionComponent.java
index e80eb8edc1d63..4ef48d08008d0 100644
--- a/core/src/main/java/hudson/ExtensionComponent.java
+++ b/core/src/main/java/hudson/ExtensionComponent.java
@@ -50,11 +50,11 @@ public ExtensionComponent(T instance, double ordinal) {
}
public ExtensionComponent(T instance, Extension annotation) {
- this(instance,annotation.ordinal());
+ this(instance, annotation.ordinal());
}
public ExtensionComponent(T instance) {
- this(instance,0);
+ this(instance, 0);
}
/**
@@ -79,7 +79,7 @@ public T getInstance() {
* For example, {@code component.isDescriptorOf(Builder.class)}
*/
public boolean isDescriptorOf(Class extends Describable> c) {
- return instance instanceof Descriptor && ((Descriptor)instance).isSubTypeOf(c);
+ return instance instanceof Descriptor && ((Descriptor) instance).isSubTypeOf(c);
}
/**
diff --git a/core/src/main/java/hudson/ExtensionFinder.java b/core/src/main/java/hudson/ExtensionFinder.java
index 10ca19bef5016..5bddd008f5f08 100644
--- a/core/src/main/java/hudson/ExtensionFinder.java
+++ b/core/src/main/java/hudson/ExtensionFinder.java
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson;
import com.google.inject.AbstractModule;
@@ -38,6 +39,7 @@
import hudson.init.InitMilestone;
import hudson.model.Descriptor;
import hudson.model.Hudson;
+import jakarta.annotation.PostConstruct;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
@@ -55,7 +57,6 @@
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
-import javax.annotation.PostConstruct;
import jenkins.ExtensionComponentSet;
import jenkins.ExtensionFilter;
import jenkins.ExtensionRefreshException;
@@ -98,7 +99,7 @@ public Collection findExtensions(Class type, Hudson hudson) {
*/
public boolean isRefreshable() {
try {
- return getClass().getMethod("refresh").getDeclaringClass()!=ExtensionFinder.class;
+ return getClass().getMethod("refresh").getDeclaringClass() != ExtensionFinder.class;
} catch (NoSuchMethodException e) {
return false;
}
@@ -153,7 +154,7 @@ public Collection> _find(Class type, Hudson hudson)
}
/**
- * Performs class initializations without creating instances.
+ * Performs class initializations without creating instances.
*
* If two threads try to initialize classes in the opposite order, a dead lock will ensue,
* and we can get into a similar situation with {@link ExtensionFinder}s.
@@ -227,7 +228,7 @@ protected GuiceExtensionAnnotation(Class annotationType) {
protected abstract boolean isOptional(T annotation);
}
-
+
/**
* Discovers components via sezpoz but instantiates them by using Guice.
*/
@@ -246,15 +247,15 @@ public static class GuiceFinder extends ExtensionFinder {
* Sezpoz index we are currently using in {@link #container} (and its ancestors.)
* Needed to compute delta.
*/
- private List> sezpozIndex;
+ private List> sezpozIndex;
- private final Map annotations = new HashMap<>();
+ private final Map annotations = new HashMap<>();
private final Sezpoz moduleFinder = new Sezpoz();
/**
* Map from {@link GuiceExtensionAnnotation#annotationType} to {@link GuiceExtensionAnnotation}
*/
- private Map,GuiceExtensionAnnotation>> extensionAnnotations = new HashMap<>();
+ private Map, GuiceExtensionAnnotation>> extensionAnnotations = new HashMap<>();
public GuiceFinder() {
refreshExtensionAnnotations();
@@ -280,14 +281,14 @@ protected void configure() {
container = Guice.createInjector(modules);
sezpozIndex = extensions.getLoadedIndex();
} catch (Throwable e) {
- LOGGER.log(Level.SEVERE, "Failed to create Guice container from all the plugins",e);
+ LOGGER.log(Level.SEVERE, "Failed to create Guice container from all the plugins", e);
// failing to load all bindings are disastrous, so recover by creating minimum that works
// by just including the core
container = Guice.createInjector(new SezpozModule(loadSezpozIndices(Jenkins.class.getClassLoader())));
}
// expose Injector via lookup mechanism for interop with non-Guice clients
- Jenkins.get().lookup.set(Injector.class,new ProxyInjector() {
+ Jenkins.get().lookup.set(Injector.class, new ProxyInjector() {
@Override
protected Injector resolve() {
return getContainer();
@@ -298,12 +299,12 @@ protected Injector resolve() {
private void refreshExtensionAnnotations() {
for (ExtensionComponent ec : moduleFinder.find(GuiceExtensionAnnotation.class, Hudson.getInstance())) {
GuiceExtensionAnnotation gea = ec.getInstance();
- extensionAnnotations.put(gea.annotationType,gea);
+ extensionAnnotations.put(gea.annotationType, gea);
}
}
private List> loadSezpozIndices(ClassLoader classLoader) {
- List> indices = new ArrayList<>();
+ List> indices = new ArrayList<>();
for (GuiceExtensionAnnotation> gea : extensionAnnotations.values()) {
for (IndexItem, Object> indexItem : Index.load(gea.annotationType, Object.class, classLoader)) {
indices.add(indexItem);
@@ -330,7 +331,7 @@ public synchronized ExtensionComponentSet refresh() throws ExtensionRefreshExcep
// figure out newly discovered sezpoz components
List> delta = new ArrayList<>();
for (Class extends Annotation> annotationType : extensionAnnotations.keySet()) {
- delta.addAll(Sezpoz.listDelta(annotationType,sezpozIndex));
+ delta.addAll(Sezpoz.listDelta(annotationType, sezpozIndex));
}
SezpozModule deltaExtensions = new SezpozModule(delta);
@@ -357,19 +358,19 @@ public Collection> find(Class type) {
}
};
} catch (Throwable e) {
- LOGGER.log(Level.SEVERE, "Failed to create Guice container from newly added plugins",e);
+ LOGGER.log(Level.SEVERE, "Failed to create Guice container from newly added plugins", e);
throw new ExtensionRefreshException(e);
}
}
- private Object instantiate(IndexItem,Object> item) {
+ private Object instantiate(IndexItem, Object> item) {
try {
return item.instance();
} catch (LinkageError | Exception e) {
// sometimes the instantiation fails in an indirect classloading failure,
// which results in a LinkageError
LOGGER.log(isOptional(item.annotation()) ? Level.FINE : Level.WARNING,
- "Failed to load "+item.className(), e);
+ "Failed to load " + item.className(), e);
}
return null;
}
@@ -388,7 +389,7 @@ private boolean isActive(Annotation annotation, AnnotatedElement e) {
public Collection> find(Class type, Hudson jenkins) {
// the find method contract requires us to traverse all known components
List> result = new ArrayList<>();
- for (Injector i=container; i!=null; i=i.getParent()) {
+ for (Injector i = container; i != null; i = i.getParent()) {
_find(type, result, i);
}
return result;
@@ -399,8 +400,8 @@ private void _find(Class type, List> result, Inject
if (type.isAssignableFrom(e.getKey().getTypeLiteral().getRawType())) {
Annotation a = annotations.get(e.getKey());
Object o = e.getValue().getProvider().get();
- if (o!=null) {
- GuiceExtensionAnnotation gea = a!=null ? extensionAnnotations.get(a.annotationType()) : null;
+ if (o != null) {
+ GuiceExtensionAnnotation gea = a != null ? extensionAnnotations.get(a.annotationType()) : null;
result.add(new ExtensionComponent<>(type.cast(o), gea != null ? gea.getOrdinal(a) : 0));
}
}
@@ -425,15 +426,17 @@ public void scout(Class extensionType, Hudson hudson) {
*/
public static final Scope FAULT_TOLERANT_SCOPE = new FaultTolerantScope(true);
private static final Scope QUIET_FAULT_TOLERANT_SCOPE = new FaultTolerantScope(false);
-
+
private static final class FaultTolerantScope implements Scope {
private final boolean verbose;
+
FaultTolerantScope(boolean verbose) {
this.verbose = verbose;
}
+
@Override
public Provider scope(final Key key, final Provider unscoped) {
- final Provider base = Scopes.SINGLETON.scope(key,unscoped);
+ final Provider base = Scopes.SINGLETON.scope(key, unscoped);
return new Provider() {
@Override
public T get() {
@@ -444,6 +447,7 @@ public T get() {
return null;
}
}
+
void error(Key key, Throwable x) {
LOGGER.log(verbose ? Level.WARNING : Level.FINE, "Failed to instantiate " + key + "; skipping this component", x);
}
@@ -459,10 +463,10 @@ void error(Key key, Throwable x) {
* so that we can take advantage of dependency injection.
*/
private class SezpozModule extends AbstractModule implements ProvisionListener {
- private final List> index;
- private final List> loadedIndex;
+ private final List> index;
+ private final List> loadedIndex;
- SezpozModule(List> index) {
+ SezpozModule(List> index) {
this.index = index;
this.loadedIndex = new ArrayList<>();
}
@@ -482,6 +486,7 @@ private class SezpozModule extends AbstractModule implements ProvisionListener {
private void resolve(Class> c) {
resolve(c, new HashSet<>());
}
+
private void resolve(Class> c, Set> encountered) {
if (!encountered.add(c)) {
return;
@@ -503,7 +508,7 @@ private void resolve(Class> c, Set> encountered) {
}
LOGGER.log(Level.FINER, "{0} looks OK", c);
} catch (RuntimeException x) {
- throw new LinkageError("Failed to resolve "+c, x);
+ throw new LinkageError("Failed to resolve " + c, x);
}
}
@@ -513,26 +518,26 @@ protected void configure() {
bindListener(Matchers.any(), this);
- for (final IndexItem,Object> item : index) {
+ for (final IndexItem, Object> item : index) {
boolean optional = isOptional(item.annotation());
try {
AnnotatedElement e = item.element();
Annotation a = item.annotation();
- if (!isActive(a,e)) continue;
+ if (!isActive(a, e)) continue;
Scope scope = optional ? QUIET_FAULT_TOLERANT_SCOPE : FAULT_TOLERANT_SCOPE;
if (e instanceof Class) {
- Key key = Key.get((Class)e);
- resolve((Class)e);
- annotations.put(key,a);
+ Key key = Key.get((Class) e);
+ resolve((Class) e);
+ annotations.put(key, a);
bind(key).in(scope);
} else {
Class extType;
if (e instanceof Field) {
- extType = ((Field)e).getType();
+ extType = ((Field) e).getType();
} else
if (e instanceof Method) {
- extType = ((Method)e).getReturnType();
+ extType = ((Method) e).getReturnType();
} else {
throw new AssertionError();
}
@@ -541,15 +546,15 @@ protected void configure() {
// make unique key, because Guice wants that.
Key key = Key.get(extType, Names.named(item.className() + "." + item.memberName()));
- annotations.put(key,a);
+ annotations.put(key, a);
bind(key).toProvider(() -> instantiate(item)).in(scope);
}
loadedIndex.add(item);
- } catch (Exception|LinkageError e) {
+ } catch (Exception | LinkageError e) {
// sometimes the instantiation fails in an indirect classloading failure,
// which results in a LinkageError
LOGGER.log(optional ? Level.FINE : Level.WARNING,
- "Failed to load "+item.className(), e);
+ "Failed to load " + item.className(), e);
}
}
}
@@ -575,7 +580,7 @@ public void onProvision(ProvisionInvocation provision) {
Arrays.stream(c.getDeclaredMethods())
.map(m -> getMethodAndInterfaceDeclarations(m, interfaces))
.flatMap(Collection::stream)
- .filter(m -> m.getAnnotation(PostConstruct.class) != null)
+ .filter(m -> m.getAnnotation(PostConstruct.class) != null || m.getAnnotation(javax.annotation.PostConstruct.class) != null)
.findFirst()
.ifPresent(method -> methods.add(0, method));
c = c.getSuperclass();
@@ -623,7 +628,7 @@ Collection getMethodAndInterfaceDeclarations(Method method, Collection> indices;
+ private volatile List> indices;
/**
* Loads indices (ideally once but as few times as possible), then reuse them later.
@@ -631,14 +636,14 @@ public static final class Sezpoz extends ExtensionFinder {
* {@link InitMilestone#PLUGINS_PREPARED} is attained, so this method is guaranteed to
* see all the classes and indices.
*/
- private List> getIndices() {
+ private List> getIndices() {
// this method cannot be synchronized because of a dead lock possibility in the following order of events:
// 1. thread X can start listing indices, locking this object 'SZ'
// 2. thread Y starts loading a class, locking a classloader 'CL'
// 3. thread X needs to load a class, now blocked on CL
// 4. thread Y decides to load extensions, now blocked on SZ.
// 5. dead lock
- if (indices==null) {
+ if (indices == null) {
ClassLoader cl = Jenkins.get().getPluginManager().uberClassLoader;
indices = Collections.unmodifiableList(StreamSupport.stream(Index.load(Extension.class, Object.class, cl).spliterator(), false).collect(Collectors.toList()));
}
@@ -653,28 +658,28 @@ private List> getIndices() {
*/
@Override
public synchronized ExtensionComponentSet refresh() {
- final List> old = indices;
- if (old==null) return ExtensionComponentSet.EMPTY; // we haven't loaded anything
+ final List> old = indices;
+ if (old == null) return ExtensionComponentSet.EMPTY; // we haven't loaded anything
- final List> delta = listDelta(Extension.class,old);
+ final List> delta = listDelta(Extension.class, old);
- List> r = new ArrayList<>(old);
+ List> r = new ArrayList<>(old);
r.addAll(delta);
indices = Collections.unmodifiableList(r);
return new ExtensionComponentSet() {
@Override
public Collection> find(Class type) {
- return _find(type,delta);
+ return _find(type, delta);
}
};
}
- static List> listDelta(Class annotationType, List extends IndexItem,Object>> old) {
+ static List> listDelta(Class annotationType, List extends IndexItem, Object>> old) {
// list up newly discovered components
- final List> delta = new ArrayList<>();
+ final List> delta = new ArrayList<>();
ClassLoader cl = Jenkins.get().getPluginManager().uberClassLoader;
- for (IndexItem ii : Index.load(annotationType, Object.class, cl)) {
+ for (IndexItem ii : Index.load(annotationType, Object.class, cl)) {
if (!old.contains(ii)) {
delta.add(ii);
}
@@ -684,28 +689,28 @@ static List> listDelta(Class annot
@Override
public Collection> find(Class type, Hudson jenkins) {
- return _find(type,getIndices());
+ return _find(type, getIndices());
}
/**
* Finds all the matching {@link IndexItem}s that match the given type and instantiate them.
*/
- private Collection> _find(Class type, List> indices) {
+ private Collection> _find(Class type, List> indices) {
List> result = new ArrayList<>();
- for (IndexItem item : indices) {
+ for (IndexItem item : indices) {
try {
Class> extType = getClassFromIndex(item);
- if(type.isAssignableFrom(extType)) {
+ if (type.isAssignableFrom(extType)) {
Object instance = item.instance();
- if(instance!=null)
- result.add(new ExtensionComponent<>(type.cast(instance),item.annotation()));
+ if (instance != null)
+ result.add(new ExtensionComponent<>(type.cast(instance), item.annotation()));
}
- } catch (LinkageError|Exception e) {
+ } catch (LinkageError | Exception e) {
// sometimes the instantiation fails in an indirect classloading failure,
// which results in a LinkageError
- LOGGER.log(logLevel(item), "Failed to load "+item.className(), e);
+ LOGGER.log(logLevel(item), "Failed to load " + item.className(), e);
}
}
@@ -714,7 +719,7 @@ private Collection> _find(Class type, List item : getIndices()) {
+ for (IndexItem item : getIndices()) {
try {
// we might end up having multiple threads concurrently calling into element(),
// but we can't synchronize this --- if we do, the one thread that's supposed to load a class
@@ -722,9 +727,9 @@ public void scout(Class extensionType, Hudson hudson) {
// looking at the sezpoz code, it should be safe to do so
Class> extType = getClassFromIndex(item);
// according to JDK-4993813 this is the only way to force class initialization
- Class.forName(extType.getName(),true,extType.getClassLoader());
+ Class.forName(extType.getName(), true, extType.getClassLoader());
} catch (Exception | LinkageError e) {
- LOGGER.log(logLevel(item), "Failed to scout "+item.className(), e);
+ LOGGER.log(logLevel(item), "Failed to scout " + item.className(), e);
}
}
}
diff --git a/core/src/main/java/hudson/ExtensionList.java b/core/src/main/java/hudson/ExtensionList.java
index c453a46b3d302..7bae8ff5d83b1 100644
--- a/core/src/main/java/hudson/ExtensionList.java
+++ b/core/src/main/java/hudson/ExtensionList.java
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
package hudson;
import edu.umd.cs.findbugs.annotations.CheckForNull;
@@ -38,6 +39,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -61,7 +63,7 @@
* and {@link jenkins.model.Jenkins#getDescriptorList(Class)} to obtain the instances.
*
* @param
- * Type of the extension point. This class holds instances of the subtypes of 'T'.
+ * Type of the extension point. This class holds instances of the subtypes of 'T'.
*
* @author Kohsuke Kawaguchi
* @since 1.286
@@ -98,11 +100,11 @@ public class ExtensionList extends AbstractList implements OnMaster {
*/
@Deprecated
protected ExtensionList(Hudson hudson, Class extensionType) {
- this((Jenkins)hudson,extensionType);
+ this((Jenkins) hudson, extensionType);
}
protected ExtensionList(Jenkins jenkins, Class extensionType) {
- this(jenkins,extensionType, new CopyOnWriteArrayList<>());
+ this(jenkins, extensionType, new CopyOnWriteArrayList<>());
}
/**
@@ -111,7 +113,7 @@ protected ExtensionList(Jenkins jenkins, Class extensionType) {
*/
@Deprecated
protected ExtensionList(Hudson hudson, Class