Skip to content
Permalink
Browse files

Revert "[JENKINS-37566] - Annotate methods which may explicitly retur…

…n `null` (#168)"

This reverts commit 5532667.
  • Loading branch information...
oleg-nenashev committed Sep 26, 2017
1 parent cbe1d4d commit 469088efd43cb657ca635fbe65396c6e675fccdd
@@ -1477,15 +1477,13 @@ public synchronized Object setProperty(Object key, Object value) {
/**
* Gets the property set on the remote peer.
*
* @return {@code null}
* @return null
* if the property of the said key isn't set.
*/
@CheckForNull
public Object getRemoteProperty(Object key) {
return remoteChannel.getProperty(key);
}

@CheckForNull
public <T> T getRemoteProperty(ChannelProperty<T> key) {
return key.type.cast(getRemoteProperty((Object) key));
}
@@ -1709,10 +1707,9 @@ public long getLastHeard() {
* objects when they are transferred to the remote {@link Channel},
* as well as during {@link Callable#call()} is invoked.
*
* @return {@code null}
* @return null
* if the calling thread is not performing serialization.
*/
@CheckForNull
public static Channel current() {
return CURRENT.get();
}
@@ -4,7 +4,6 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import javax.annotation.CheckForNull;

/**
* Lower level abstraction under {@link Channel} for sending and receiving commands
@@ -180,7 +179,6 @@
* This method is package private, to prevent new {@link CommandTransport} from
* providing this feature.
*/
@CheckForNull
OutputStream getUnderlyingStream() {
return null;
}
@@ -27,7 +27,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
import javax.annotation.CheckForNull;

/**
* Manages unique ID for classloaders.
@@ -55,7 +54,6 @@ public synchronized int intern(ClassLoader cl) {
return id;
}

@CheckForNull
public synchronized ClassLoader get(int id) {
WeakReference<ClassLoader> ref = table.get(id);
if(ref==null) return null;
@@ -1,11 +1,5 @@
package hudson.remoting;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;

/**
* Exception that prints like the specified exception.
*
@@ -17,7 +11,6 @@
* @deprecated Use {@link ProxyException} instead.
*/
@Deprecated
@Restricted(DoNotUse.class)
class MimicException extends Exception {
private final String className;
MimicException(Throwable cause) {
@@ -36,8 +29,7 @@ public String toString() {
return (message != null) ? (s + ": " + message) : s;
}

@Nullable
public static Throwable make(@Nonnull Channel ch, @Nullable Throwable cause) {
public static Throwable make(Channel ch, Throwable cause) {
if (cause == null) return null;

// make sure the remoting layer of the other end supports this
@@ -16,7 +16,6 @@
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;

/**
* {@link ObjectInputStream}/{@link ObjectOutputStream} pair that can handle object graph that spans across
@@ -88,7 +87,6 @@ protected void annotateProxyClass(Class<?> cl) throws IOException {
this.channel = channel;
}

@CheckForNull
private ClassLoader readClassLoader() throws IOException, ClassNotFoundException {
ClassLoader cl;
int code = readInt();
@@ -124,7 +122,6 @@ private ClassLoader readClassLoader() throws IOException, ClassNotFoundException
channel.classFilter.check(name);
try {
ClassLoader cl = readClassLoader();
// TODO: handle null classloader as a System one?
Class<?> c = Class.forName(name, false, cl);
channel.classFilter.check(c);
return c;
@@ -139,7 +136,6 @@ private ClassLoader readClassLoader() throws IOException, ClassNotFoundException

Class[] classes = new Class[interfaces.length];
for (int i = 0; i < interfaces.length; i++)
// TODO: handle null classloader as a System one?
classes[i] = Class.forName(interfaces[i], false, cl);

/*
@@ -402,7 +402,6 @@ private void definePackage(String name) {
definePackage(packageName, null, null, null, null, null, null, null);
}

@CheckForNull
public URL findResource(String name) {
// first attempt to load from locally fetched jars
URL url = super.findResource(name);
@@ -895,7 +894,6 @@ public ClassFile2 fetch4(String className, ClassFile2 referer) throws ClassNotFo
return all;
}

@CheckForNull
private URL getResourceURL(String name) throws IOException {
URL resource = cl.getResource(name);
if (resource == null) {
@@ -912,7 +910,6 @@ private URL getResourceURL(String name) throws IOException {
return resource;
}

@CheckForNull
public ResourceFile getResource2(String name) throws IOException {
URL resource = getResourceURL(name);
if (resource == null) return null;
@@ -941,7 +938,6 @@ private ResourceFile makeResource(String name, URL resource) throws IOException
@Override
@SuppressFBWarnings(value = "PZLA_PREFER_ZERO_LENGTH_ARRAYS",
justification = "Null return value is a part of the public interface")
@CheckForNull
public byte[] getResource(String name) throws IOException {
URL resource = getResourceURL(name);
if (resource == null) return null;
@@ -51,7 +51,6 @@
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jenkinsci.remoting.RoleChecker;

/**
@@ -216,7 +215,6 @@ public static int unwrap(Object proxy, Channel src) {
* If the given object is a proxy object, return the {@link Channel}
* object that it's associated with. Otherwise null.
*/
@CheckForNull
public static Channel unwrap(Object proxy) {
InvocationHandler h = Proxy.getInvocationHandler(proxy);
if (h instanceof RemoteInvocationHandler) {
@@ -226,7 +224,6 @@ public static Channel unwrap(Object proxy) {
return null;
}

@Nullable
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if(method.getDeclaringClass()==IReadResolve.class) {
// readResolve on the proxy.
@@ -134,7 +134,6 @@ public void setTunnel(String tunnel) {
this.tunnel = tunnel;
}

@CheckForNull
public JnlpAgentEndpoint resolve() throws IOException {
IOException firstError = null;
for (String jenkinsUrl : jenkinsUrls) {
@@ -22,7 +22,6 @@
import java.nio.channels.spi.SelectorProvider;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;

/**
* Extracts out {@link SelectableChannel} from {@link InputStream} or {@link OutputStream}.
@@ -44,8 +43,6 @@
* @since 2.38
*/
public class SelectableFileChannelFactory {

@CheckForNull
protected FileInputStream unwrap(InputStream i) {
if (i instanceof BufferedInputStream) {
try {
@@ -66,7 +63,6 @@ protected FileInputStream unwrap(InputStream i) {
return null; // unknown type
}

@CheckForNull
protected FileOutputStream unwrap(OutputStream i) {
if (i instanceof BufferedOutputStream) {
try {
@@ -87,36 +83,24 @@ protected FileOutputStream unwrap(OutputStream i) {
return null; // unknown type
}

@CheckForNull
public SocketChannel create(InputStream in) throws IOException {
return create(unwrap(in));
}

@CheckForNull
public SocketChannel create(OutputStream out) throws IOException {
return create(unwrap(out));
}

@CheckForNull
public SocketChannel create(FileInputStream in) throws IOException {
if (in==null) return null;
return create(in.getFD());
}

@CheckForNull
public SocketChannel create(FileOutputStream out) throws IOException {
if (out==null) return null;
return create(out.getFD());
}

/**
* Create channel using the specified file descriptor.
*
* @param fd File Descriptor
* @return {@code null} if the platform does not support it (e.g. Windows) OR the socket channel cannot be created.
* In the latter case the error message will be printed to {@link #LOGGER} then.
*/
@CheckForNull
public SocketChannel create(FileDescriptor fd) {
if (File.pathSeparatorChar==';')
return null; // not selectable on Windows

0 comments on commit 469088e

Please sign in to comment.
You can’t perform that action at this time.