Navigation Menu

Skip to content

Commit

Permalink
0000817: Take only the first 50 characters of an ipaddress in order t…
Browse files Browse the repository at this point in the history
…o make sure database save to tables doesn't fail
  • Loading branch information
chenson42 committed Sep 12, 2012
1 parent 8e80e2d commit 7708a1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Expand Up @@ -23,6 +23,7 @@
import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.jumpmind.symmetric.Version;
import org.jumpmind.symmetric.util.AppUtils;

Expand All @@ -35,6 +36,8 @@ public class NodeHost implements Serializable {

public static Date LAST_RESTART_TIME = new Date();

protected final static int MAX_IP_ADDRESS_SIZE = 50;

private String nodeId;
private String hostName;
private String ipAddress;
Expand Down Expand Up @@ -62,11 +65,11 @@ public NodeHost(String nodeId) {
this.nodeId = nodeId;
this.refresh();
this.createTime = new Date();
}
}

public void refresh() {
this.hostName = AppUtils.getHostName();
this.ipAddress = AppUtils.getIpAddress();
setIpAddress(AppUtils.getIpAddress());
this.osUser = System.getProperty("user.name");
this.osName = System.getProperty("os.name");
this.osArch = System.getProperty("os.arch");
Expand Down Expand Up @@ -103,7 +106,7 @@ public String getIpAddress() {
}

public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
this.ipAddress = StringUtils.left(ipAddress, MAX_IP_ADDRESS_SIZE);
}

public String getOsUser() {
Expand Down
Expand Up @@ -23,6 +23,8 @@
import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang.StringUtils;

public class RegistrationRequest implements Serializable {

private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -52,7 +54,7 @@ public RegistrationRequest(Node node, RegistrationStatus status,
this.registeredNodeId = node.getNodeId();
this.status = status;
this.hostName = hostName == null ? "unknown" : hostName;
this.ipAddress = ipAddress == null ? "unknown" : ipAddress;
setIpAddress(ipAddress);
}

public String getNodeGroupId() {
Expand Down Expand Up @@ -92,7 +94,8 @@ public String getIpAddress() {
}

public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
this.ipAddress = StringUtils.left(ipAddress == null ? "unknown" : ipAddress,
NodeHost.MAX_IP_ADDRESS_SIZE);
}

public long getAttemptCount() {
Expand Down

0 comments on commit 7708a1b

Please sign in to comment.