Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions core/src/main/java/hudson/FilePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -2715,14 +2715,6 @@ private void syncIO() throws InterruptedException {
}
}

/**
* A pointless function to work around what appears to be a HotSpot problem. See JENKINS-5756 and bug 6933067
* on BugParade for more details.
*/
private void _syncIO() throws InterruptedException {
channel.syncLocalIO();
}

/**
* Remoting interface used for {@link FilePath#copyRecursiveTo(String, FilePath)}.
*
Expand Down
9 changes: 0 additions & 9 deletions core/src/main/java/hudson/model/AbstractItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -636,15 +636,6 @@ private static class Replacer {
Replacer(AbstractItem i) {
fullName = i.getFullName();
}

private Object readResolve() {
Copy link
Contributor

@mawinter69 mawinter69 Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not remove any method with name readResolve or writeReplace
These methods even when private are used by during serialization of Objects.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again out bug sorry. yes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jenkins j = Jenkins.getInstanceOrNull();
if (j == null) {
return null;
}
// Will generally only work if called after job loading:
return j.getItemByFullName(fullName);
}
}

/**
Expand Down
123 changes: 0 additions & 123 deletions core/src/main/java/hudson/model/DirectoryBrowserSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,19 @@
import java.util.Collection;
import java.util.Comparator;
import java.util.GregorianCalendar;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import jenkins.model.Jenkins;
import jenkins.security.MasterToSlaveCallable;
import jenkins.security.ResourceDomainConfiguration;
import jenkins.security.ResourceDomainRootAction;
import jenkins.util.SystemProperties;
import jenkins.util.VirtualFile;
import org.apache.commons.io.IOUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.HttpResponse;
Expand Down Expand Up @@ -439,57 +432,6 @@ private boolean hasTmpDir(VirtualFile baseFile, String base, OpenOption[] openOp
return FilePath.isIgnoreTmpDirs(openOptions) && TMPDIR_PATTERN.matcher(base).matches();
}

private List<List<Path>> keepReadabilityOnlyOnDescendants(VirtualFile root, boolean patternUsed, List<List<Path>> pathFragmentsList) {
Stream<List<Path>> pathFragmentsStream = pathFragmentsList.stream().map((List<Path> pathFragments) -> {
List<Path> mappedFragments = new ArrayList<>(pathFragments.size());
String relativePath = "";
for (int i = 0; i < pathFragments.size(); i++) {
Path current = pathFragments.get(i);
if (i == 0) {
relativePath = current.title;
} else {
relativePath += "/" + current.title;
}

if (!current.isReadable) {
if (patternUsed) {
// we do not want to leak information about existence of folders / files satisfying the pattern inside that folder
return null;
}
mappedFragments.add(current);
return mappedFragments;
} else {
if (isDescendant(root, relativePath)) {
mappedFragments.add(current);
} else {
if (patternUsed) {
// we do not want to leak information about existence of folders / files satisfying the pattern inside that folder
return null;
}
mappedFragments.add(Path.createNotReadableVersionOf(current));
return mappedFragments;
}
}
}
return mappedFragments;
});

if (patternUsed) {
pathFragmentsStream = pathFragmentsStream.filter(Objects::nonNull);
}

return pathFragmentsStream.collect(Collectors.toList());
}

private boolean isDescendant(VirtualFile root, String relativePath) {
try {
return ALLOW_SYMLINK_ESCAPE || !root.supportIsDescendant() || root.isDescendant(relativePath);
}
catch (IOException e) {
return false;
}
}

private String getPath(StaplerRequest2 req) {
String path = req.getRestOfPath();
if (path.isEmpty())
Expand Down Expand Up @@ -519,71 +461,6 @@ private static String createBackRef(int times) {
return "../".repeat(times);
}

private static void zip(StaplerResponse2 rsp, VirtualFile root, VirtualFile dir, String glob) throws IOException, InterruptedException {
OutputStream outputStream = rsp.getOutputStream();
// TODO JENKINS-20663 make encoding overridable via query parameter
try (ZipOutputStream zos = new ZipOutputStream(outputStream, Charset.defaultCharset())) {
// TODO consider using run(Callable) here

if (glob.isEmpty()) {
if (!root.supportsQuickRecursiveListing()) {
// avoid slow listing when the Glob can do a quicker job
glob = "**";
}
}

if (glob.isEmpty()) {
Map<String, VirtualFile> nameToVirtualFiles = collectRecursivelyAllLegalChildren(dir);
sendZipUsingMap(zos, dir, nameToVirtualFiles);
} else {
Collection<String> listOfFile = dir.list(glob, null, /* TODO what is the user expectation? */true);
sendZipUsingListOfNames(zos, dir, listOfFile);
}
}
}

private static void sendZipUsingMap(ZipOutputStream zos, VirtualFile dir, Map<String, VirtualFile> nameToVirtualFiles) throws IOException {
for (Map.Entry<String, VirtualFile> entry : nameToVirtualFiles.entrySet()) {
String n = entry.getKey();

// JENKINS-19947: traditional behavior is to prepend the directory name
String relativePath = dir.getName() + '/' + n;

VirtualFile f = entry.getValue();
sendOneZipEntry(zos, f, relativePath);
}
}

private static void sendZipUsingListOfNames(ZipOutputStream zos, VirtualFile dir, Collection<String> listOfFileNames) throws IOException {
for (String relativePath : listOfFileNames) {
VirtualFile f = dir.child(relativePath);
sendOneZipEntry(zos, f, relativePath);
}
}

private static void sendOneZipEntry(ZipOutputStream zos, VirtualFile vf, String relativePath) throws IOException {
// In ZIP archives "All slashes MUST be forward slashes" (http://pkware.com/documents/casestudies/APPNOTE.TXT)
// TODO On Linux file names can contain backslashes which should not treated as file separators.
// Unfortunately, only the file separator char of the controller is known (File.separatorChar)
// but not the file separator char of the (maybe remote) "dir".
ZipEntry e = new ZipEntry(relativePath.replace('\\', '/'));

e.setTime(vf.lastModified());
zos.putNextEntry(e);
try (InputStream in = vf.open()) {
IOUtils.copy(in, zos);
}
finally {
zos.closeEntry();
}
}

private static Map<String, VirtualFile> collectRecursivelyAllLegalChildren(VirtualFile dir) throws IOException {
Map<String, VirtualFile> nameToFiles = new LinkedHashMap<>();
collectRecursivelyAllLegalChildren(dir, "", nameToFiles);
return nameToFiles;
}

private static void collectRecursivelyAllLegalChildren(VirtualFile currentDir, String currentPrefix, Map<String, VirtualFile> nameToFiles) throws IOException {
if (currentDir.isFile()) {
if (currentDir.isDescendant("")) {
Expand Down
12 changes: 0 additions & 12 deletions core/src/main/java/hudson/model/LoadStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,6 @@ protected void doRun() {

j.overallLoad.updateCounts(j.overallLoad.computeSnapshot(bis));
}

private int count(List<Queue.BuildableItem> bis, Label l) {
int q = 0;
for (Queue.BuildableItem bi : bis) {
for (SubTask st : bi.task.getSubTasks()) {
if (bi.getAssignedLabelFor(st) == l) {
q++;
}
}
}
return q;
}
}

/**
Expand Down
5 changes: 0 additions & 5 deletions core/src/main/java/hudson/model/PaneStatusProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public void save() throws IOException {
user.save();
}

private Object readResolve() {
collapsed.setOwner(this);
return this;
}

@Extension @Symbol("paneStatus")
public static class DescriptorImpl extends UserPropertyDescriptor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ public ParametersDefinitionProperty(@NonNull ParameterDefinition... parameterDef
this.parameterDefinitions = parameterDefinitions != null ? Arrays.asList(parameterDefinitions) : new ArrayList<>();
}

private Object readResolve() {
return parameterDefinitions == null ? new ParametersDefinitionProperty() : this;
}


public final String getBuildButtonText() {
return AlternativeUiTextProvider.get(BUILD_BUTTON_TEXT, owner, Messages.ParametersDefinitionProperty_BuildButtonText());
Expand Down
10 changes: 0 additions & 10 deletions core/src/main/java/hudson/model/Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,6 @@ public void setSorter(QueueSorter sorter) {
public static final class State {
public /* almost final */ List<Item> items = new ArrayList<>();
public /* almost final */ Map<String, Object> properties = new HashMap<>();

private Object readResolve() {
if (items == null) {
items = new ArrayList<>();
}
if (properties == null) {
properties = new HashMap<>();
}
return this;
}
}

/**
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/java/hudson/model/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -2036,10 +2036,6 @@ private static class Replacer {
Replacer(Run<?, ?> r) {
id = r.getExternalizableId();
}

private Object readResolve() {
return fromExternalizableId(id);
}
}

/**
Expand Down
17 changes: 0 additions & 17 deletions core/src/main/java/hudson/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -780,14 +780,6 @@ public static void clear() {
UserIdMapper.getInstance().clear();
AllUsers.clear();
}

private static File getConfigFileFor(String id) {
return new File(getUserFolderFor(id), "config.xml");
}

private static File getUserFolderFor(String id) {
return new File(getRootDir(), idStrategy().filenameOf(id));
}
/**
* Returns the folder that store all the user information.
* Useful for plugins to save a user-specific file aside the config.xml.
Expand Down Expand Up @@ -1050,21 +1042,12 @@ public Object getTarget() {
return new HashSet<>(Arrays.asList(ILLEGAL_PERSISTED_USERNAMES));
}

private Object writeReplace() {
return XmlFile.replaceIfNotAtTopLevel(this, () -> new Replacer(this));
}

private static class Replacer {
private final String id;

Replacer(User u) {
id = u.getId();
}

private Object readResolve() {
// Will generally only work if called after UserIdMapper.init:
return getById(id, false);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,6 @@ public T get(Computer c) {
return record.data.get(c);
}

/**
* Is the monitoring activity currently in progress?
*/
private synchronized boolean isInProgress() {
return inProgress != null && inProgress.isAlive();
}

/**
* The timestamp that indicates when the last round of the monitoring has completed.
*/
Expand Down
7 changes: 0 additions & 7 deletions core/src/main/java/hudson/security/SecurityRealm.java
Original file line number Diff line number Diff line change
Expand Up @@ -786,13 +786,6 @@ public Filter createFilter(FilterConfig filterConfig) {
return new ChainedServletFilter2();
}

/**
* Maintain singleton semantics.
*/
private Object readResolve() {
return NO_AUTHENTICATION;
}

@Extension(ordinal = -100)
@Symbol("none")
public static class DescriptorImpl extends Descriptor<SecurityRealm> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public boolean isExcludeClientIPFromCrumb() {
return this.excludeClientIPFromCrumb;
}

private Object readResolve() {
initializeMessageDigest();
return this;
}

private synchronized void initializeMessageDigest() {
try {
md = MessageDigest.getInstance("SHA-256");
Expand Down
18 changes: 0 additions & 18 deletions core/src/main/java/hudson/slaves/OfflineCause.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.model.Computer;
import hudson.model.User;
import java.io.ObjectStreamException;
import java.util.Collections;
import jenkins.agents.IOfflineCause;
import jenkins.model.Jenkins;
import org.jvnet.localizer.Localizable;
Expand Down Expand Up @@ -169,22 +167,6 @@ public String getMessage() {
return message;
}

// Storing the User in a filed was a mistake, switch to userId
private Object readResolve() throws ObjectStreamException {
if (user != null) {
String id = user.getId();
if (id != null) {
userId = id;
} else {
// The user field is not properly deserialized so id may be missing. Look the user up by fullname
User user = User.get(this.user.getFullName(), true, Collections.emptyMap());
userId = user.getId();
}
this.user = null;
}
return this;
}

@Override
@NonNull
public String getComputerIcon() {
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/java/hudson/slaves/RetentionStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ public Descriptor<RetentionStrategy<?>> getDescriptor() {
return DESCRIPTOR;
}

private Object readResolve() {
return NOOP;
}

private static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();

private static final class DescriptorImpl extends Descriptor<RetentionStrategy<?>> {}
Expand Down
Loading
Loading