提交 33f458d3 编写于 作者: O Oleg Nenashev 提交者: GitHub

Merge pull request #2519 from oleg-nenashev/findbugs/JENKINS-36720-medium-level-fb

[JENKINS-36720] - Cleanup of SOME medium FindBugs issues
......@@ -192,6 +192,10 @@ public class CLI implements AutoCloseable {
rsp.write(ch);
}
String head = new BufferedReader(new StringReader(rsp.toString("ISO-8859-1"))).readLine();
if (head == null) {
throw new IOException("Unexpected empty response");
}
if (!(head.startsWith("HTTP/1.0 200 ") || head.startsWith("HTTP/1.1 200 "))) {
s.close();
LOGGER.log(Level.SEVERE, "Failed to tunnel the CLI port through the HTTP proxy. Falling back to HTTP.");
......
......@@ -137,8 +137,7 @@ public class FullDuplexHttpStream {
if (authorization != null) {
con.addRequestProperty("Authorization", authorization);
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
try (BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
String line = reader.readLine();
String nextLine = reader.readLine();
if (nextLine != null) {
......
......@@ -78,6 +78,7 @@ import java.beans.Introspector;
import java.util.IdentityHashMap;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Metadata about a configurable instance.
......@@ -563,7 +564,7 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable,
* Signals a problem in the submitted form.
* @since 1.145
*/
public T newInstance(@CheckForNull StaplerRequest req, @Nonnull JSONObject formData) throws FormException {
public T newInstance(@Nullable StaplerRequest req, @Nonnull JSONObject formData) throws FormException {
try {
Method m = getClass().getMethod("newInstance", StaplerRequest.class);
......
......@@ -23,6 +23,7 @@
*/
package hudson.tasks;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.FilePath;
import jenkins.MasterToSlaveFileCallable;
import hudson.Launcher;
......@@ -139,6 +140,8 @@ public class ArtifactArchiver extends Recorder implements SimpleBuildStep {
}
// Backwards compatibility for older builds
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
justification = "Null checks in readResolve are valid since we deserialize and upgrade objects")
public Object readResolve() {
if (allowEmptyArchive == null) {
this.allowEmptyArchive = SystemProperties.getBoolean(ArtifactArchiver.class.getName()+".warnOnEmpty");
......@@ -226,7 +229,8 @@ public class ArtifactArchiver extends Recorder implements SimpleBuildStep {
return;
}
if (onlyIfSuccessful && build.getResult() != null && build.getResult().isWorseThan(Result.UNSTABLE)) {
Result result = build.getResult();
if (onlyIfSuccessful && result != null && result.isWorseThan(Result.UNSTABLE)) {
listener.getLogger().println(Messages.ArtifactArchiver_SkipBecauseOnlyIfSuccessful());
return;
}
......@@ -242,7 +246,7 @@ public class ArtifactArchiver extends Recorder implements SimpleBuildStep {
new Fingerprinter(artifacts).perform(build, ws, launcher, listener);
}
} else {
Result result = build.getResult();
result = build.getResult();
if (result != null && result.isBetterOrEqualTo(Result.UNSTABLE)) {
// If the build failed, don't complain that there was no matching artifact.
// The build probably didn't even get to the point where it produces artifacts.
......
......@@ -306,15 +306,22 @@ public class XStream2 extends XStream {
this.xstream = xstream;
}
private Converter findConverter(Class<?> t) {
@CheckForNull
private Converter findConverter(@CheckForNull Class<?> t) {
if (t == null) {
return null;
}
Converter result = cache.get(t);
if (result != null)
// ConcurrentHashMap does not allow null, so use this object to represent null
return result == this ? null : result;
try {
if(t==null || t.getClassLoader()==null)
final ClassLoader classLoader = t.getClassLoader();
if(classLoader == null) {
return null;
Class<?> cl = t.getClassLoader().loadClass(t.getName() + "$ConverterImpl");
}
Class<?> cl = classLoader.loadClass(t.getName() + "$ConverterImpl");
Constructor<?> c = cl.getConstructors()[0];
Class<?>[] p = c.getParameterTypes();
......
......@@ -22,6 +22,7 @@ import com.sun.jna.Pointer;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.ptr.IntByReference;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Arrays;
import java.util.List;
......@@ -318,6 +319,7 @@ typedef struct _SERVICE_STATUS {
DWORD dwWaitHint;
} SERVICE_STATUS,
*LPSERVICE_STATUS;*/
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", justification = "JNA Data Structure")
class SERVICE_STATUS extends Structure {
public int dwServiceType;
public int dwCurrentState;
......@@ -342,6 +344,7 @@ typedef struct _SERVICE_TABLE_ENTRY {
LPSERVICE_MAIN_FUNCTION lpServiceProc;
} SERVICE_TABLE_ENTRY,
*LPSERVICE_TABLE_ENTRY;*/
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", justification = "JNA Data Structure")
class SERVICE_TABLE_ENTRY extends Structure {
public String lpServiceName;
public SERVICE_MAIN_FUNCTION lpServiceProc;
......@@ -365,6 +368,7 @@ typedef struct _SERVICE_TABLE_ENTRY {
LPTSTR lpDescription;
} SERVICE_DESCRIPTION,
*LPSERVICE_DESCRIPTION;*/
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", justification = "JNA Data Structure")
class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
public String lpDescription;
}
......
......@@ -26,6 +26,7 @@ package hudson.util.jna;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Arrays;
import java.util.List;
......@@ -56,6 +57,7 @@ typedef struct _SHELLEXECUTEINFO {
* @author Kohsuke Kawaguchi
* @see <a href="http://msdn.microsoft.com/en-us/library/bb759784(v=VS.85).aspx">MSDN: SHELLEXECUTEINFO</a>
*/
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", justification = "JNA Data Structure")
public class SHELLEXECUTEINFO extends Structure {
public int cbSize = size();
public int fMask;
......@@ -85,6 +87,7 @@ public class SHELLEXECUTEINFO extends Structure {
"hProcess");
}
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", justification = "JNA Data Structure")
public static class DUMMYUNIONNAME_union extends Union {
public Pointer hIcon;
public Pointer hMonitor;
......
......@@ -17,6 +17,7 @@ package hudson.util.jna;
import com.sun.jna.Structure;
import com.sun.jna.Pointer;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Arrays;
import java.util.List;
......@@ -33,6 +34,7 @@ typedef struct _SECURITY_ATTRIBUTES {
} SECURITY_ATTRIBUTES,
*PSECURITY_ATTRIBUTES,
*LPSECURITY_ATTRIBUTES;*/
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", justification = "JNA Data Structure")
class SECURITY_ATTRIBUTES extends Structure {
public int nLength;
public Pointer lpSecurityDescriptor;
......@@ -50,6 +52,7 @@ typedef struct _FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME, *PFILETIME, *LPFILETIME;*/
@SuppressFBWarnings(value = "UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD", justification = "JNA Data Structure")
class FILETIME extends Structure {
public int dwLowDateTime;
public int dwHighDateTime;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册