Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make FolderComputation implement Loadable #365

Merged
merged 2 commits into from
Jan 24, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.ExtensionList;
import hudson.Util;
import hudson.XmlFile;
import hudson.model.Action;
import hudson.model.BuildableItem;
import hudson.model.Cause;
Expand Down Expand Up @@ -216,13 +215,10 @@
LOGGER.log(Level.WARNING, null, x);
}
synchronized (this) {
XmlFile file = computation.getDataFile();
if (file.exists()) {
try {
file.unmarshal(computation);
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to load " + file, e);
}
try {
computation.load();
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to load " + computation, e);

Check warning on line 221 in src/main/java/com/cloudbees/hudson/plugins/folder/computed/ComputedFolder.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 221 is not covered by tests
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import com.jcraft.jzlib.GZIPInputStream;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.AbortException;
import hudson.BulkChange;
Expand Down Expand Up @@ -76,6 +75,7 @@
import javax.servlet.ServletException;
import net.jcip.annotations.GuardedBy;
import java.nio.charset.StandardCharsets;
import jenkins.model.Loadable;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.jelly.XMLOutput;
Expand All @@ -89,7 +89,7 @@
* A particular “run” of {@link ComputedFolder}.
* @since 4.11-beta-1
*/
public class FolderComputation<I extends TopLevelItem> extends Actionable implements Queue.Executable, Saveable {
public class FolderComputation<I extends TopLevelItem> extends Actionable implements Queue.Executable, Saveable, Loadable {

/**
* Our logger.
Expand Down Expand Up @@ -203,6 +203,7 @@
*/
@Override
public void save() throws IOException {
LOGGER.fine(() -> "saving " + this);
if (BulkChange.contains(this)) {
return;
}
Expand All @@ -211,6 +212,15 @@
SaveableListener.fireOnChange(this, dataFile);
}

@Override
public void load() throws IOException {
LOGGER.fine(() -> "loading " + this);
XmlFile dataFile = getDataFile();
if (dataFile.exists()) {

Check warning on line 219 in src/main/java/com/cloudbees/hudson/plugins/folder/computed/FolderComputation.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 219 is only partially covered, one branch is missing
dataFile.unmarshal(this);
}
}

@NonNull
public File getLogFile() {
return new File(folder.getComputationDir(), "computation.log");
Expand Down
Loading