Skip to content

Commit b741860

Browse files
authored
Use Java 17 language features (jenkinsci#1206)
instanceof pattern matching Add @serial annotation
1 parent d3d43f1 commit b741860

17 files changed

+39
-3
lines changed

src/main/java/hudson/plugins/git/Branch.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package hudson.plugins.git;
22

3+
import java.io.Serial;
34
import java.util.Objects;
45
import org.eclipse.jgit.lib.ObjectId;
56
import org.eclipse.jgit.lib.Ref;
@@ -8,6 +9,7 @@
89
* Represents a git branch.
910
*/
1011
public class Branch extends GitObject {
12+
@Serial
1113
private static final long serialVersionUID = 1L;
1214

1315
/**

src/main/java/hudson/plugins/git/GitAPI.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
*/
2929
@Deprecated
3030
public class GitAPI extends CliGitAPIImpl {
31+
@Serial
3132
private static final long serialVersionUID = 1L;
33+
3234
private final GitClient jgit;
3335

3436
/**

src/main/java/hudson/plugins/git/GitException.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package hudson.plugins.git;
22

3+
import java.io.Serial;
4+
35
/**
46
* Records exception information related to git operations. This exception is
57
* used to encapsulate command line git errors, JGit errors, and other errors
68
* related to git operations.
79
*/
810
public class GitException extends RuntimeException {
11+
@Serial
912
private static final long serialVersionUID = 1L;
1013

1114
/**

src/main/java/hudson/plugins/git/GitLockFailedException.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package hudson.plugins.git;
22

3+
import java.io.Serial;
4+
35
/**
46
* Exception which reports failure to lock a git repository. Lock failures are
57
* a special case and may indicate that a retry attempt might succeed.
68
*/
79
public class GitLockFailedException extends GitException {
10+
@Serial
811
private static final long serialVersionUID = 1L;
912

1013
/**

src/main/java/hudson/plugins/git/GitObject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package hudson.plugins.git;
22

33
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4+
import java.io.Serial;
45
import java.io.Serializable;
56
import java.util.Objects;
67
import org.eclipse.jgit.lib.ObjectId;
@@ -14,6 +15,7 @@
1415
@ExportedBean(defaultVisibility = 999)
1516
public class GitObject implements Serializable {
1617

18+
@Serial
1719
private static final long serialVersionUID = 1L;
1820

1921
final ObjectId sha1;

src/main/java/hudson/plugins/git/GitTool.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import hudson.util.FormValidation;
1818
import java.io.File;
1919
import java.io.IOException;
20+
import java.io.Serial;
2021
import java.util.ArrayList;
2122
import java.util.Collections;
2223
import java.util.List;
@@ -53,6 +54,7 @@ public GitTool(String name, String home, List<? extends ToolProperty<?>> propert
5354
/** Constant <code>DEFAULT="Default"</code> */
5455
public static final transient String DEFAULT = "Default";
5556

57+
@Serial
5658
private static final long serialVersionUID = 1;
5759

5860
/**

src/main/java/hudson/plugins/git/IndexEntry.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package hudson.plugins.git;
22

3+
import java.io.Serial;
34
import java.io.Serializable;
45
import java.util.Objects;
56
import org.eclipse.jgit.submodule.SubmoduleWalk;
@@ -155,5 +156,6 @@ public IndexEntry(SubmoduleWalk walk) {
155156
this("160000", "commit", walk.getObjectId().name(), walk.getPath());
156157
}
157158

159+
@Serial
158160
private static final long serialVersionUID = 1L;
159161
}

src/main/java/hudson/plugins/git/Revision.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
66
import hudson.Util;
7+
import java.io.Serial;
78
import java.util.ArrayList;
89
import java.util.Collection;
910
import org.eclipse.jgit.lib.ObjectId;
@@ -19,6 +20,7 @@
1920
*/
2021
@ExportedBean(defaultVisibility = 999)
2122
public class Revision implements java.io.Serializable, Cloneable {
23+
@Serial
2224
private static final long serialVersionUID = -7203898556389073882L;
2325

2426
ObjectId sha1;

src/main/java/hudson/plugins/git/Tag.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package hudson.plugins.git;
22

3+
import java.io.Serial;
34
import java.util.Objects;
45
import org.eclipse.jgit.lib.ObjectId;
56

67
/**
78
* Git tag including SHA1 and message of the associated commit.
89
*/
910
public class Tag extends GitObject {
11+
@Serial
1012
private static final long serialVersionUID = 1L;
1113
/** SHA1 hash of the tagged commit */
1214
public String commitSHA1;

src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ public class CliGitAPIImpl extends LegacyCompatibleGitAPIImpl {
183183

184184
private static final Logger LOGGER = Logger.getLogger(CliGitAPIImpl.class.getName());
185185

186+
@Serial
186187
private static final long serialVersionUID = 1;
188+
187189
static final String SPARSE_CHECKOUT_FILE_DIR = ".git/info";
188190
static final String SPARSE_CHECKOUT_FILE_PATH = ".git/info/sparse-checkout";
189191
static final String TIMEOUT_LOG_PREFIX = " # timeout=";

0 commit comments

Comments
 (0)