Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-4224

Slave changes hash code when its name changes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • core
    • None
    • Platform: All, OS: All

      Create a slave. Get its hash code. Rename the slave. Get its hash code now.
      Expected: the hash code remains the same, even when instance data such as the
      name changes.
      Actual: the hash code changes when the name is changed.

      Similarly, two slaves are considered equals() when they have the same name.

      Here are tests for both of those related issues:

      public class SlaveTest extends HudsonTestCase {

      public void testSlaveIdentity() throws Exception

      { Label niceLabel = hudson.getLabel("nice"); Slave slave = createSlave(niceLabel); int originalHashCode = slave.hashCode(); slave.setNodeName("beandip"); int hashCodeAfterRename = slave.hashCode(); assertEquals("Hash code was preserved when the node's name changed", originalHashCode, hashCodeAfterRename); }

      public void testSlaveRenaming() throws Exception

      { Label niceLabel = hudson.getLabel("nice"); Label pinkLabel = hudson.getLabel("pink"); Slave slave = createSlave(niceLabel); Slave anotherSlave = createSlave(pinkLabel); assertFalse( "Two different slaves should be different", slave.equals(anotherSlave)); String newName = "sailor"; slave.setNodeName(newName); anotherSlave.setNodeName(newName); assertEquals("names are the same", slave.getNodeName(), anotherSlave.getNodeName()); assertFalse( "Two different slaves should not be equals() eachother", slave.equals(anotherSlave)); }


      }

            Unassigned Unassigned
            bshine bshine
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: