Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2887

Data insertion error occurs when using a custom Address with JDBC_PING2

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 5.3.19, 5.5.0, 5.4.9
    • 5.5.0
    • None
    • False
    • Hide

      None

      Show
      None
    • False

      We are using a custom implementation of the Address class in our JGroups setup. When combining this custom address format with JDBC_PING2, we encounter a data insertion error at runtime.

      The error log is as follows:

      JDBC_PING2.error:99]21:250529140510: failed writing to DB: java.sql.SQLIntegrityConstraintViolationException: Column 'address' cannot be null

      The root cause appears to be in the following method in JDBC_PING2:

      public static String addressToString(Address addr) {
          if (addr == null)
              return null;
          if (addr.isSiteAddress())

      { // SiteUUID         SiteUUID su = (SiteUUID) addr;         return String.format("%s%s:%s:%s", SITE_UUID_PREFIX, su.toStringLong(), su.getName(), su.getSite());     }

          Class<? extends Address> cl = addr.getClass();
          if (UUID.class.isAssignableFrom(cl)) // UUID, FlagsUUID, ExtendedUUID
              return String.format("%s%s", UUID_PREFIX, ((UUID) addr).toStringLong());
          if (IpAddress.class.equals(cl))
              return String.format("%s%s", IP_PREFIX, addr);
          return null;
      }

      Since our custom Address class does not fall into any of the known types (UUID, SiteUUID, or IpAddress), this method returns null. As a result, the address column in the database ends up being null, causing a SQL error

              rhn-engineering-bban Bela Ban
              leon_a chen baoyi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: