Skip to content

Commit

Permalink
Add missing nullability annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
offa committed Dec 8, 2021
1 parent 9911031 commit dcc50de
Show file tree
Hide file tree
Showing 18 changed files with 79 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public ListenableFuture<?> apply(final Function<StepExecution, Void> f) {
all.add(execs);
Futures.addCallback(execs,new FutureCallback<List<StepExecution>>() {
@Override
public void onSuccess(List<StepExecution> result) {
public void onSuccess(@NonNull List<StepExecution> result) {
for (StepExecution e : result) {
try {
f.apply(e);
Expand All @@ -199,7 +199,7 @@ public void onSuccess(List<StepExecution> result) {
}

@Override
public void onFailure(Throwable t) {
public void onFailure(@NonNull Throwable t) {
LOGGER.log(Level.WARNING, null, t);
}
}, MoreExecutors.directExecutor());
Expand Down Expand Up @@ -238,7 +238,7 @@ public static class ResumeStepExecutionListener extends FlowExecutionListener {
public void onResumed(@NonNull FlowExecution e) {
Futures.addCallback(e.getCurrentExecutions(false), new FutureCallback<List<StepExecution>>() {
@Override
public void onSuccess(List<StepExecution> result) {
public void onSuccess(@NonNull List<StepExecution> result) {
if (e.isComplete()) {
// WorkflowRun.onLoad will not fire onResumed if the serialized execution was already
// complete when loaded, but right now (at least for workflow-cps), the execution resumes
Expand All @@ -263,7 +263,7 @@ public void onSuccess(List<StepExecution> result) {
}

@Override
public void onFailure(Throwable t) {
public void onFailure(@NonNull Throwable t) {
if (t instanceof CancellationException) {
LOGGER.log(Level.FINE, "Cancelled load of " + e, t);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public static FlowExecutionOwner dummyOwner() {

private static class DummyOwner extends FlowExecutionOwner {
DummyOwner() {}
@NonNull
@Override public FlowExecution get() throws IOException {
throw new IOException("not implemented");
}
Expand All @@ -174,6 +175,7 @@ private static class DummyOwner extends FlowExecutionOwner {
@Override public int hashCode() {
return 0;
}
@NonNull
@Override public TaskListener getListener() {
return TaskListener.NULL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public DescriptorImpl() {
/** Null to use the platform default, which may change over time as enhanced options are available. */
private FlowDurabilityHint durabilityHint = null;

@NonNull
@Override
public String getDisplayName() {
return "Global Default Pipeline Durability Level";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ private synchronized void loadActions() {
}

@Exported
@NonNull
@SuppressWarnings("deprecation") // of override
@Override
@SuppressFBWarnings(value = "UG_SYNC_SET_UNSYNC_GET", justification = "CopyOnWrite ArrayList, and field load & modification is synchronized")
Expand Down Expand Up @@ -466,7 +467,7 @@ public int size() {
}

@Override
public boolean removeAll(Collection<?> c) {
public boolean removeAll(@NonNull Collection<?> c) {
boolean changed = actions.removeAll(c);
if (changed) {
persistSafe();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package org.jenkinsci.plugins.workflow.graph;

import edu.umd.cs.findbugs.annotations.NonNull;
import org.jenkinsci.plugins.workflow.flow.FlowExecution;

import java.util.List;
Expand All @@ -44,6 +45,7 @@ public FlowStartNode(FlowExecution exec, String id) {
* @deprecated
* Why are you calling a method that always return empty list?
*/
@NonNull
@Override
public List<FlowNode> getParents() {
return super.getParents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class FilteratorImpl<T> implements Filterator<T> {
private Iterator<T> wrapped = null;
private Predicate<T> matchCondition = null;

@NonNull
@Override
public FilteratorImpl<T> filter(Predicate<T> matchCondition) {
public FilteratorImpl<T> filter(@NonNull Predicate<T> matchCondition) {
return new FilteratorImpl<>(this, matchCondition);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected FlowNode jumpBlockScan(@CheckForNull FlowNode node, @NonNull Collectio
}

@Override
protected FlowNode next(@NonNull FlowNode current, @NonNull Collection<FlowNode> blackList) {
protected FlowNode next(@CheckForNull FlowNode current, @NonNull Collection<FlowNode> blackList) {
if (current == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package org.jenkinsci.plugins.workflow.graphanalysis;

import com.google.common.base.Predicate;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.jenkinsci.plugins.workflow.graph.FlowNode;

Expand Down Expand Up @@ -78,7 +79,7 @@ protected void setHeads(@NonNull Collection<FlowNode> heads) {
}

@Override
protected FlowNode next(FlowNode current, @NonNull Collection<FlowNode> blackList) {
protected FlowNode next(@CheckForNull FlowNode current, @NonNull Collection<FlowNode> blackList) {
if (current == null) {
return null;
}
Expand All @@ -98,8 +99,9 @@ protected FlowNode next(FlowNode current, @NonNull Collection<FlowNode> blackLis
* @deprecated prefer {@link #filteredNodes(FlowNode, Predicate)}
*/
@Deprecated
@NonNull
@Override
public List<FlowNode> filteredNodes(Collection<FlowNode> heads, Predicate<FlowNode> matchPredicate) {
public List<FlowNode> filteredNodes(Collection<FlowNode> heads, @NonNull Predicate<FlowNode> matchPredicate) {
return super.filteredNodes(heads, matchPredicate);
}

Expand All @@ -109,6 +111,7 @@ public List<FlowNode> filteredNodes(Collection<FlowNode> heads, Predicate<FlowNo
* {@inheritDoc}
* @param heads Nodes to start iterating backward from by visiting their parents. <strong>Do not pass multiple heads.</strong>
*/
@NonNull
@Override
public List<FlowNode> filteredNodes(Collection<FlowNode> heads, Collection<FlowNode> blackList, Predicate<FlowNode> matchCondition) {
return super.filteredNodes(heads, blackList, matchCondition);
Expand All @@ -120,7 +123,7 @@ public List<FlowNode> filteredNodes(Collection<FlowNode> heads, Collection<FlowN
*/
@Deprecated
@Override
public FlowNode findFirstMatch(Collection<FlowNode> heads, Predicate<FlowNode> matchPredicate) {
public FlowNode findFirstMatch(Collection<FlowNode> heads, @NonNull Predicate<FlowNode> matchPredicate) {
return super.findFirstMatch(heads, matchPredicate);
}

Expand All @@ -142,7 +145,7 @@ public FlowNode findFirstMatch(Collection<FlowNode> heads, Collection<FlowNode>
* @param heads <strong>Do not pass multiple heads.</strong>
*/
@Override
public void visitAll(Collection<FlowNode> heads, FlowNodeVisitor visitor) {
public void visitAll(Collection<FlowNode> heads, @NonNull FlowNodeVisitor visitor) {
super.visitAll(heads, visitor);
}

Expand All @@ -153,7 +156,7 @@ public void visitAll(Collection<FlowNode> heads, FlowNodeVisitor visitor) {
* @param heads Nodes to start walking the DAG backwards from. <strong>Do not pass multiple heads.</strong>
*/
@Override
public void visitAll(Collection<FlowNode> heads, Collection<FlowNode> blackList, FlowNodeVisitor visitor) {
public void visitAll(Collection<FlowNode> heads, Collection<FlowNode> blackList, @NonNull FlowNodeVisitor visitor) {
super.visitAll(heads, blackList, visitor);
}

Expand All @@ -163,7 +166,7 @@ public void visitAll(Collection<FlowNode> heads, Collection<FlowNode> blackList,
*/
@Deprecated
@Override
public FlowNode findFirstMatch(FlowExecution exec, Predicate<FlowNode> matchPredicate) {
public FlowNode findFirstMatch(FlowExecution exec, @NonNull Predicate<FlowNode> matchPredicate) {
return super.findFirstMatch(exec, matchPredicate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public MemoryFlowChunk() {

}

@NonNull
@Override
public FlowNode getFirstNode() {
return firstNode;
Expand All @@ -60,7 +61,7 @@ public void setFirstNode(FlowNode firstNode) {
this.firstNode = firstNode;
}


@NonNull
@Override
public FlowNode getLastNode() {
return lastNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ public interface ParallelFlowChunk <ChunkType extends FlowChunk> extends FlowChu
@NonNull
Map<String, ChunkType> getBranches();

@NonNull
void setBranch(@NonNull String branchName, @NonNull ChunkType branchBlock);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package org.jenkinsci.plugins.workflow.log;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Functions;
import hudson.console.AnnotatedLargeText;
import hudson.model.BuildListener;
Expand All @@ -47,20 +48,24 @@ public final class BrokenLogStorage implements LogStorage {
public BrokenLogStorage(Throwable x) {
this.x = x;
}


@NonNull
@Override public BuildListener overallListener() throws IOException {
throw new IOException(x);
}

@Override public TaskListener nodeListener(FlowNode node) throws IOException {

@NonNull
@Override public TaskListener nodeListener(@NonNull FlowNode node) throws IOException {
throw new IOException(x);
}

@Override public AnnotatedLargeText<FlowExecutionOwner.Executable> overallLog(FlowExecutionOwner.Executable build, boolean complete) {

@NonNull
@Override public AnnotatedLargeText<FlowExecutionOwner.Executable> overallLog(@NonNull FlowExecutionOwner.Executable build, boolean complete) {
return new BrokenAnnotatedLargeText<>();
}

@Override public AnnotatedLargeText<FlowNode> stepLog(FlowNode node, boolean complete) {

@NonNull
@Override public AnnotatedLargeText<FlowNode> stepLog(@NonNull FlowNode node, boolean complete) {
return new BrokenAnnotatedLargeText<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package org.jenkinsci.plugins.workflow.log;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.CloseProofOutputStream;
import hudson.model.BuildListener;
Expand All @@ -49,7 +50,8 @@ final class BufferedBuildListener implements BuildListener, Closeable, Serializa
this.out = out;
ps = new PrintStream(out, false, "UTF-8");
}


@NonNull
@Override public PrintStream getLogger() {
return ps;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.util.Timer;
import org.jenkinsci.remoting.SerializableOnlyOverRemoting;

Expand Down Expand Up @@ -121,7 +123,7 @@ private static final class FlushControlledOutputStream extends FilterOutputStrea
super(out);
}

@Override public void write(byte[] b, int off, int len) throws IOException {
@Override public void write(@NonNull byte[] b, int off, int len) throws IOException {
out.write(b, off, len); // super method writes one byte at a time!
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package org.jenkinsci.plugins.workflow.log;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.console.AnnotatedLargeText;
import hudson.console.ConsoleAnnotationOutputStream;
Expand Down Expand Up @@ -111,11 +112,13 @@ private synchronized void open() throws IOException {
}
}

@NonNull
@Override public BuildListener overallListener() throws IOException {
return new BufferedBuildListener(new IndexOutputStream(null));
}

@Override public TaskListener nodeListener(FlowNode node) throws IOException {
@NonNull
@Override public TaskListener nodeListener(@NonNull FlowNode node) throws IOException {
return new BufferedBuildListener(new IndexOutputStream(node.getId()));
}

Expand Down Expand Up @@ -153,14 +156,14 @@ private final class IndexOutputStream extends OutputStream {
}
}

@Override public void write(byte[] b) throws IOException {
@Override public void write(@NonNull byte[] b) throws IOException {
synchronized (FileLogStorage.this) {
checkId(id);
bos.write(b);
}
}

@Override public void write(byte[] b, int off, int len) throws IOException {
@Override public void write(@NonNull byte[] b, int off, int len) throws IOException {
synchronized (FileLogStorage.this) {
checkId(id);
bos.write(b, off, len);
Expand Down Expand Up @@ -194,7 +197,8 @@ private void maybeFlush() {
}
}

@Override public AnnotatedLargeText<FlowExecutionOwner.Executable> overallLog(FlowExecutionOwner.Executable build, boolean complete) {
@NonNull
@Override public AnnotatedLargeText<FlowExecutionOwner.Executable> overallLog(@NonNull FlowExecutionOwner.Executable build, boolean complete) {
maybeFlush();
return new AnnotatedLargeText<FlowExecutionOwner.Executable>(log, StandardCharsets.UTF_8, complete, build) {
@Override public long writeHtmlTo(long start, Writer w) throws IOException {
Expand Down Expand Up @@ -252,7 +256,8 @@ private void maybeFlush() {
};
}

@Override public AnnotatedLargeText<FlowNode> stepLog(FlowNode node, boolean complete) {
@NonNull
@Override public AnnotatedLargeText<FlowNode> stepLog(@NonNull FlowNode node, boolean complete) {
maybeFlush();
String id = node.getId();
try (ByteBuffer buf = new ByteBuffer();
Expand Down Expand Up @@ -323,7 +328,8 @@ private void maybeFlush() {
}

@Deprecated
@Override public File getLogFile(FlowExecutionOwner.Executable build, boolean complete) {
@NonNull
@Override public File getLogFile(@NonNull FlowExecutionOwner.Executable build, boolean complete) {
return log;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.util.Timer;

/**
Expand All @@ -48,7 +50,7 @@ final class GCFlushedOutputStream extends FilterOutputStream {
FlushRef.register(this, out);
}

@Override public void write(byte[] b, int off, int len) throws IOException {
@Override public void write(@NonNull byte[] b, int off, int len) throws IOException {
out.write(b, off, len); // super method is surprising
}

Expand Down
Loading

0 comments on commit dcc50de

Please sign in to comment.