Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-45055] - Annotate other non-deprecated API methods
  • Loading branch information
oleg-nenashev committed Jun 22, 2017
1 parent af1bcc6 commit 62dc34b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
11 changes: 6 additions & 5 deletions src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java
Expand Up @@ -35,7 +35,7 @@ public class EnvInjectAction implements RunAction2, StaplerProxy {
@Restricted(NoExternalUse.class)
protected transient @CheckForNull Map<String, String> envMap;

private transient @Nonnull Run<?, ?> build;
private transient @CheckForNull Run<?, ?> build;

@Override
public void onAttached(Run<?, ?> run) {
Expand Down Expand Up @@ -73,8 +73,6 @@ public EnvInjectAction(@Nonnull AbstractBuild build,
* @param envMap Environment Map
* @since 0.25
*/
@SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR",
justification = "RunAction2 handlers in the core should do it in all valid use-cases")
public EnvInjectAction(@CheckForNull Map<String, String> envMap) {
this.envMap = envMap;
}
Expand All @@ -99,6 +97,7 @@ public void overrideAll(
}

@SuppressWarnings({"unused", "unchecked"})
@CheckForNull
public Map<String, String> getEnvMap() {
if (envMap == null) {
//Try to fill the envMap from the build injected environment
Expand Down Expand Up @@ -152,7 +151,7 @@ public String transformEntry(String key, String value) {
return this;
}


@CheckForNull
private Map<String, String> getEnvironment(@CheckForNull Run<?, ?> build) throws EnvInjectException {

if (build == null) {
Expand All @@ -170,9 +169,11 @@ private Map<String, String> getEnvironment(@CheckForNull Run<?, ?> build) throws

/**
* Retrieves an owner {@link Run} of this action.
* @return {@link Run}, which contains the action
* @return {@link Run}, which contains the action.
* May be {@code null} if and only if the action is not attached to the run.
* @since TODO
*/
@CheckForNull
public Run<?,?> getOwner() {
return build;
}
Expand Down
@@ -1,19 +1,23 @@
package org.jenkinsci.lib.envinject;

import javax.annotation.Nonnull;

/**
* Exception type for the EnvInject logic.
*
* @author Gregory Boissinot
*/
public class EnvInjectException extends Exception {

public EnvInjectException(String s) {
public EnvInjectException(@Nonnull String s) {
super(s);
}

public EnvInjectException(Throwable throwable) {
public EnvInjectException(@Nonnull Throwable throwable) {
super(throwable);
}

public EnvInjectException(String s, Throwable throwable) {
public EnvInjectException(@Nonnull String s, @Nonnull Throwable throwable) {
super(s, throwable);
}
}
11 changes: 7 additions & 4 deletions src/main/java/org/jenkinsci/lib/envinject/EnvInjectLogger.java
Expand Up @@ -3,27 +3,30 @@
import hudson.model.TaskListener;

import java.io.Serializable;
import javax.annotation.Nonnull;

/**
* @author Gregory Boissinot
*/
public class EnvInjectLogger implements Serializable {

private TaskListener listener;
@Nonnull
private final TaskListener listener;

public EnvInjectLogger(TaskListener listener) {
public EnvInjectLogger(@Nonnull TaskListener listener) {
this.listener = listener;
}

@Nonnull
public TaskListener getListener() {
return listener;
}

public void info(String message) {
public void info(@Nonnull String message) {
listener.getLogger().println("[EnvInject] - " + message);
}

public void error(String message) {
public void error(@Nonnull String message) {
listener.getLogger().println("[EnvInject] - [ERROR] - " + message);
}
}
Expand Down

0 comments on commit 62dc34b

Please sign in to comment.