Merge branch 'refactoring/JENKINS-47896-serializableOnlyOverRemoting' of github.com:oleg-nenashev/jenkins into SerializableOnlyOverRemoting-JENKINS-47896

This commit is contained in:
Jesse Glick committed 2019-04-11 15:58:57 -04:00
commit 7c3810a82e
3 files changed
+15 -12

No files matched your search

+7 -7
View File
@@ -130,6 +130,7 @@ import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import org.jenkinsci.remoting.RoleChecker;
import org.jenkinsci.remoting.RoleSensitive;
import org.jenkinsci.remoting.SerializableOnlyOverRemoting;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.Function;
@@ -207,7 +208,7 @@ import org.apache.tools.ant.BuildException;
* @author Kohsuke Kawaguchi
* @see VirtualFile
*/
public final class FilePath implements Serializable {
public final class FilePath implements SerializableOnlyOverRemoting {
/**
* Maximum http redirects we will follow. This defaults to the same number as Firefox/Chrome tolerates.
*/
@@ -2985,18 +2986,17 @@ public final class FilePath implements Serializable {
}
private void writeObject(ObjectOutputStream oos) throws IOException {
Channel target = Channel.current();
if(channel!=null && channel!=target)
throw new IllegalStateException("Can't send a remote FilePath to a different remote channel");
Channel target = getChannelForSerialization();
if (channel != null && channel != target) {
throw new IllegalStateException("Can't send a remote FilePath to a different remote channel (current=" + channel + ", target=" + target + ")");
}
oos.defaultWriteObject();
oos.writeBoolean(channel==null);
}
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
Channel channel = Channel.current();
assert channel!=null;
Channel channel = getChannelForSerialization();
ois.defaultReadObject();
if(ois.readBoolean()) {