Skip to content

Commit de4be3e

Browse files
author
Vincent Potucek
committed
Apply staticanalysis.RemoveUnusedPrivateMethods
1 parent 79f9ebd commit de4be3e

40 files changed

+0
-405
lines changed

core/src/main/java/hudson/FilePath.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,14 +2715,6 @@ private void syncIO() throws InterruptedException {
27152715
}
27162716
}
27172717

2718-
/**
2719-
* A pointless function to work around what appears to be a HotSpot problem. See JENKINS-5756 and bug 6933067
2720-
* on BugParade for more details.
2721-
*/
2722-
private void _syncIO() throws InterruptedException {
2723-
channel.syncLocalIO();
2724-
}
2725-
27262718
/**
27272719
* Remoting interface used for {@link FilePath#copyRecursiveTo(String, FilePath)}.
27282720
*

core/src/main/java/hudson/model/AbstractItem.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -636,15 +636,6 @@ private static class Replacer {
636636
Replacer(AbstractItem i) {
637637
fullName = i.getFullName();
638638
}
639-
640-
private Object readResolve() {
641-
Jenkins j = Jenkins.getInstanceOrNull();
642-
if (j == null) {
643-
return null;
644-
}
645-
// Will generally only work if called after job loading:
646-
return j.getItemByFullName(fullName);
647-
}
648639
}
649640

650641
/**

core/src/main/java/hudson/model/DirectoryBrowserSupport.java

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import java.io.OutputStream;
3737
import java.io.Serializable;
3838
import java.net.URL;
39-
import java.nio.charset.Charset;
4039
import java.nio.charset.StandardCharsets;
4140
import java.nio.file.LinkOption;
4241
import java.nio.file.OpenOption;
@@ -47,26 +46,19 @@
4746
import java.util.Collection;
4847
import java.util.Comparator;
4948
import java.util.GregorianCalendar;
50-
import java.util.LinkedHashMap;
5149
import java.util.List;
5250
import java.util.Locale;
5351
import java.util.Map;
54-
import java.util.Objects;
5552
import java.util.StringTokenizer;
5653
import java.util.logging.Level;
5754
import java.util.logging.Logger;
5855
import java.util.regex.Pattern;
59-
import java.util.stream.Collectors;
60-
import java.util.stream.Stream;
61-
import java.util.zip.ZipEntry;
62-
import java.util.zip.ZipOutputStream;
6356
import jenkins.model.Jenkins;
6457
import jenkins.security.MasterToSlaveCallable;
6558
import jenkins.security.ResourceDomainConfiguration;
6659
import jenkins.security.ResourceDomainRootAction;
6760
import jenkins.util.SystemProperties;
6861
import jenkins.util.VirtualFile;
69-
import org.apache.commons.io.IOUtils;
7062
import org.kohsuke.accmod.Restricted;
7163
import org.kohsuke.accmod.restrictions.NoExternalUse;
7264
import org.kohsuke.stapler.HttpResponse;
@@ -439,57 +431,6 @@ private boolean hasTmpDir(VirtualFile baseFile, String base, OpenOption[] openOp
439431
return FilePath.isIgnoreTmpDirs(openOptions) && TMPDIR_PATTERN.matcher(base).matches();
440432
}
441433

442-
private List<List<Path>> keepReadabilityOnlyOnDescendants(VirtualFile root, boolean patternUsed, List<List<Path>> pathFragmentsList) {
443-
Stream<List<Path>> pathFragmentsStream = pathFragmentsList.stream().map((List<Path> pathFragments) -> {
444-
List<Path> mappedFragments = new ArrayList<>(pathFragments.size());
445-
String relativePath = "";
446-
for (int i = 0; i < pathFragments.size(); i++) {
447-
Path current = pathFragments.get(i);
448-
if (i == 0) {
449-
relativePath = current.title;
450-
} else {
451-
relativePath += "/" + current.title;
452-
}
453-
454-
if (!current.isReadable) {
455-
if (patternUsed) {
456-
// we do not want to leak information about existence of folders / files satisfying the pattern inside that folder
457-
return null;
458-
}
459-
mappedFragments.add(current);
460-
return mappedFragments;
461-
} else {
462-
if (isDescendant(root, relativePath)) {
463-
mappedFragments.add(current);
464-
} else {
465-
if (patternUsed) {
466-
// we do not want to leak information about existence of folders / files satisfying the pattern inside that folder
467-
return null;
468-
}
469-
mappedFragments.add(Path.createNotReadableVersionOf(current));
470-
return mappedFragments;
471-
}
472-
}
473-
}
474-
return mappedFragments;
475-
});
476-
477-
if (patternUsed) {
478-
pathFragmentsStream = pathFragmentsStream.filter(Objects::nonNull);
479-
}
480-
481-
return pathFragmentsStream.collect(Collectors.toList());
482-
}
483-
484-
private boolean isDescendant(VirtualFile root, String relativePath) {
485-
try {
486-
return ALLOW_SYMLINK_ESCAPE || !root.supportIsDescendant() || root.isDescendant(relativePath);
487-
}
488-
catch (IOException e) {
489-
return false;
490-
}
491-
}
492-
493434
private String getPath(StaplerRequest2 req) {
494435
String path = req.getRestOfPath();
495436
if (path.isEmpty())
@@ -519,71 +460,6 @@ private static String createBackRef(int times) {
519460
return "../".repeat(times);
520461
}
521462

522-
private static void zip(StaplerResponse2 rsp, VirtualFile root, VirtualFile dir, String glob) throws IOException, InterruptedException {
523-
OutputStream outputStream = rsp.getOutputStream();
524-
// TODO JENKINS-20663 make encoding overridable via query parameter
525-
try (ZipOutputStream zos = new ZipOutputStream(outputStream, Charset.defaultCharset())) {
526-
// TODO consider using run(Callable) here
527-
528-
if (glob.isEmpty()) {
529-
if (!root.supportsQuickRecursiveListing()) {
530-
// avoid slow listing when the Glob can do a quicker job
531-
glob = "**";
532-
}
533-
}
534-
535-
if (glob.isEmpty()) {
536-
Map<String, VirtualFile> nameToVirtualFiles = collectRecursivelyAllLegalChildren(dir);
537-
sendZipUsingMap(zos, dir, nameToVirtualFiles);
538-
} else {
539-
Collection<String> listOfFile = dir.list(glob, null, /* TODO what is the user expectation? */true);
540-
sendZipUsingListOfNames(zos, dir, listOfFile);
541-
}
542-
}
543-
}
544-
545-
private static void sendZipUsingMap(ZipOutputStream zos, VirtualFile dir, Map<String, VirtualFile> nameToVirtualFiles) throws IOException {
546-
for (Map.Entry<String, VirtualFile> entry : nameToVirtualFiles.entrySet()) {
547-
String n = entry.getKey();
548-
549-
// JENKINS-19947: traditional behavior is to prepend the directory name
550-
String relativePath = dir.getName() + '/' + n;
551-
552-
VirtualFile f = entry.getValue();
553-
sendOneZipEntry(zos, f, relativePath);
554-
}
555-
}
556-
557-
private static void sendZipUsingListOfNames(ZipOutputStream zos, VirtualFile dir, Collection<String> listOfFileNames) throws IOException {
558-
for (String relativePath : listOfFileNames) {
559-
VirtualFile f = dir.child(relativePath);
560-
sendOneZipEntry(zos, f, relativePath);
561-
}
562-
}
563-
564-
private static void sendOneZipEntry(ZipOutputStream zos, VirtualFile vf, String relativePath) throws IOException {
565-
// In ZIP archives "All slashes MUST be forward slashes" (http://pkware.com/documents/casestudies/APPNOTE.TXT)
566-
// TODO On Linux file names can contain backslashes which should not treated as file separators.
567-
// Unfortunately, only the file separator char of the controller is known (File.separatorChar)
568-
// but not the file separator char of the (maybe remote) "dir".
569-
ZipEntry e = new ZipEntry(relativePath.replace('\\', '/'));
570-
571-
e.setTime(vf.lastModified());
572-
zos.putNextEntry(e);
573-
try (InputStream in = vf.open()) {
574-
IOUtils.copy(in, zos);
575-
}
576-
finally {
577-
zos.closeEntry();
578-
}
579-
}
580-
581-
private static Map<String, VirtualFile> collectRecursivelyAllLegalChildren(VirtualFile dir) throws IOException {
582-
Map<String, VirtualFile> nameToFiles = new LinkedHashMap<>();
583-
collectRecursivelyAllLegalChildren(dir, "", nameToFiles);
584-
return nameToFiles;
585-
}
586-
587463
private static void collectRecursivelyAllLegalChildren(VirtualFile currentDir, String currentPrefix, Map<String, VirtualFile> nameToFiles) throws IOException {
588464
if (currentDir.isFile()) {
589465
if (currentDir.isDescendant("")) {

core/src/main/java/hudson/model/LoadStatistics.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -370,18 +370,6 @@ protected void doRun() {
370370

371371
j.overallLoad.updateCounts(j.overallLoad.computeSnapshot(bis));
372372
}
373-
374-
private int count(List<Queue.BuildableItem> bis, Label l) {
375-
int q = 0;
376-
for (Queue.BuildableItem bi : bis) {
377-
for (SubTask st : bi.task.getSubTasks()) {
378-
if (bi.getAssignedLabelFor(st) == l) {
379-
q++;
380-
}
381-
}
382-
}
383-
return q;
384-
}
385373
}
386374

387375
/**

core/src/main/java/hudson/model/PaneStatusProperties.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ public void save() throws IOException {
4040
user.save();
4141
}
4242

43-
private Object readResolve() {
44-
collapsed.setOwner(this);
45-
return this;
46-
}
47-
4843
@Extension @Symbol("paneStatus")
4944
public static class DescriptorImpl extends UserPropertyDescriptor {
5045

core/src/main/java/hudson/model/ParametersDefinitionProperty.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ public ParametersDefinitionProperty(@NonNull ParameterDefinition... parameterDef
8989
this.parameterDefinitions = parameterDefinitions != null ? Arrays.asList(parameterDefinitions) : new ArrayList<>();
9090
}
9191

92-
private Object readResolve() {
93-
return parameterDefinitions == null ? new ParametersDefinitionProperty() : this;
94-
}
95-
9692

9793
public final String getBuildButtonText() {
9894
return AlternativeUiTextProvider.get(BUILD_BUTTON_TEXT, owner, Messages.ParametersDefinitionProperty_BuildButtonText());

core/src/main/java/hudson/model/Queue.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,6 @@ public void setSorter(QueueSorter sorter) {
377377
public static final class State {
378378
public /* almost final */ List<Item> items = new ArrayList<>();
379379
public /* almost final */ Map<String, Object> properties = new HashMap<>();
380-
381-
private Object readResolve() {
382-
if (items == null) {
383-
items = new ArrayList<>();
384-
}
385-
if (properties == null) {
386-
properties = new HashMap<>();
387-
}
388-
return this;
389-
}
390380
}
391381

392382
/**

core/src/main/java/hudson/model/Run.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,10 +2036,6 @@ private static class Replacer {
20362036
Replacer(Run<?, ?> r) {
20372037
id = r.getExternalizableId();
20382038
}
2039-
2040-
private Object readResolve() {
2041-
return fromExternalizableId(id);
2042-
}
20432039
}
20442040

20452041
/**

core/src/main/java/hudson/model/User.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -780,14 +780,6 @@ public static void clear() {
780780
UserIdMapper.getInstance().clear();
781781
AllUsers.clear();
782782
}
783-
784-
private static File getConfigFileFor(String id) {
785-
return new File(getUserFolderFor(id), "config.xml");
786-
}
787-
788-
private static File getUserFolderFor(String id) {
789-
return new File(getRootDir(), idStrategy().filenameOf(id));
790-
}
791783
/**
792784
* Returns the folder that store all the user information.
793785
* Useful for plugins to save a user-specific file aside the config.xml.
@@ -1050,21 +1042,12 @@ public Object getTarget() {
10501042
return new HashSet<>(Arrays.asList(ILLEGAL_PERSISTED_USERNAMES));
10511043
}
10521044

1053-
private Object writeReplace() {
1054-
return XmlFile.replaceIfNotAtTopLevel(this, () -> new Replacer(this));
1055-
}
1056-
10571045
private static class Replacer {
10581046
private final String id;
10591047

10601048
Replacer(User u) {
10611049
id = u.getId();
10621050
}
1063-
1064-
private Object readResolve() {
1065-
// Will generally only work if called after UserIdMapper.init:
1066-
return getById(id, false);
1067-
}
10681051
}
10691052

10701053
/**

core/src/main/java/hudson/node_monitors/AbstractNodeMonitorDescriptor.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,6 @@ public T get(Computer c) {
196196
return record.data.get(c);
197197
}
198198

199-
/**
200-
* Is the monitoring activity currently in progress?
201-
*/
202-
private synchronized boolean isInProgress() {
203-
return inProgress != null && inProgress.isAlive();
204-
}
205-
206199
/**
207200
* The timestamp that indicates when the last round of the monitoring has completed.
208201
*/

0 commit comments

Comments
 (0)