Skip to content
Permalink
Browse files
fix for jenkins-bug #JENKINS-17165
overriding method readResolve() from base-class BPHostConfiguration for
resolving Reflection-problems with XStream
  • Loading branch information
afischer211 committed Apr 15, 2013
1 parent b4d594a commit aa3399f7c266a9d105d63e98dda654a34d110bc7
@@ -28,10 +28,15 @@
import hudson.model.Describable;
import hudson.model.Hudson;
import hudson.util.Secret;

import java.io.IOException;
import java.io.PrintWriter;

import jenkins.plugins.publish_over.BPBuildInfo;
import jenkins.plugins.publish_over.BPHostConfiguration;
import jenkins.plugins.publish_over.BapPublisherException;
import jenkins.plugins.publish_over_ftp.descriptor.BapFtpHostConfigurationDescriptor;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -42,9 +47,6 @@
import org.apache.commons.net.ftp.FTPReply;
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.IOException;
import java.io.PrintWriter;

@SuppressWarnings("PMD.TooManyMethods")
public class BapFtpHostConfiguration extends BPHostConfiguration<BapFtpClient, Object> implements Describable<BapFtpHostConfiguration> {

@@ -60,15 +62,16 @@

@DataBoundConstructor
public BapFtpHostConfiguration(final String name, final String hostname, final String username, final String encryptedPassword,
final String remoteRootDir, final int port, final int timeout, final boolean useActiveData,
final String controlEncoding, final boolean disableMakeNestedDirs) {
final String remoteRootDir, final int port, final int timeout, final boolean useActiveData,
final String controlEncoding, final boolean disableMakeNestedDirs) {
super(name, hostname, username, encryptedPassword, remoteRootDir, port);
this.timeout = timeout;
this.useActiveData = useActiveData;
this.controlEncoding = Util.fixEmptyAndTrim(controlEncoding);
this.disableMakeNestedDirs = disableMakeNestedDirs;
}

@Override
protected final String getPassword() {
return super.getPassword();
}
@@ -94,7 +97,7 @@ public BapFtpClient createClient(final BPBuildInfo buildInfo) {
init(client);
} catch (IOException ioe) {
throw new BapPublisherException(Messages.exception_failedToCreateClient(
ioe.getClass().getName() + ": " + ioe.getLocalizedMessage()), ioe);
ioe.getClass().getName() + ": " + ioe.getLocalizedMessage()), ioe);
}
return client;
}
@@ -185,6 +188,7 @@ public BapFtpHostConfigurationDescriptor getDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapFtpHostConfigurationDescriptor.class);
}

@Override
protected HashCodeBuilder addToHashCode(final HashCodeBuilder builder) {
return super.addToHashCode(builder)
.append(useActiveData)
@@ -199,26 +203,34 @@ protected EqualsBuilder addToEquals(final EqualsBuilder builder, final BapFtpHos
.append(controlEncoding, that.controlEncoding);
}

@Override
protected ToStringBuilder addToToString(final ToStringBuilder builder) {
return super.addToToString(builder)
.append("useActiveData", useActiveData)
.append("timeout", timeout)
.append("controlEncoding", controlEncoding);
}

@Override
public boolean equals(final Object that) {
if (this == that) return true;
if (that == null || getClass() != that.getClass()) return false;

return addToEquals(new EqualsBuilder(), (BapFtpHostConfiguration) that).isEquals();
}

@Override
public int hashCode() {
return addToHashCode(new HashCodeBuilder()).toHashCode();
}

@Override
public String toString() {
return addToToString(new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)).toString();
}

@Override
public Object readResolve() {
return super.readResolve();
}
}
@@ -26,26 +26,28 @@

import hudson.Extension;
import hudson.model.Hudson;

import java.util.ArrayList;

import jenkins.plugins.publish_over.BPPlugin;
import jenkins.plugins.publish_over.BPPluginDescriptor;
import jenkins.plugins.publish_over_ftp.descriptor.BapFtpPublisherPluginDescriptor;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.kohsuke.stapler.DataBoundConstructor;

import java.util.ArrayList;

@SuppressWarnings("PMD.LooseCoupling") // serializable
public class BapFtpPublisherPlugin extends BPPlugin<BapFtpPublisher, BapFtpClient, Object> {

private static final long serialVersionUID = 1L;

@DataBoundConstructor
public BapFtpPublisherPlugin(final ArrayList<BapFtpPublisher> publishers, final boolean continueOnError, final boolean failOnError,
final boolean alwaysPublishFromMaster, final String masterNodeName,
final BapFtpParamPublish paramPublish) {
final boolean alwaysPublishFromMaster, final String masterNodeName,
final BapFtpParamPublish paramPublish) {
super(Messages.console_message_prefix(), publishers, continueOnError, failOnError, alwaysPublishFromMaster, masterNodeName,
paramPublish);
}
@@ -54,17 +56,20 @@ public BapFtpParamPublish getParamPublish() {
return (BapFtpParamPublish) getDelegate().getParamPublish();
}

@Override
public boolean equals(final Object that) {
if (this == that) return true;
if (that == null || getClass() != that.getClass()) return false;

return addToEquals(new EqualsBuilder(), (BapFtpPublisherPlugin) that).isEquals();
}

@Override
public int hashCode() {
return addToHashCode(new HashCodeBuilder()).toHashCode();
}

@Override
public String toString() {
return addToToString(new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)).toString();
}
@@ -79,7 +84,12 @@ public BapFtpHostConfiguration getConfiguration(final String name) {
}

@Extension
public static class Descriptor extends BapFtpPublisherPluginDescriptor { }
public static class Descriptor extends BapFtpPublisherPluginDescriptor {
@Override
public Object readResolve() {
return super.readResolve();
}
}

/** left in to prevent xstream noise */
@Deprecated

This file was deleted.

0 comments on commit aa3399f

Please sign in to comment.