accumulo icon indicating copy to clipboard operation
accumulo copied to clipboard

MetadataSchema convenience Text methods for constants does not enforce strict immutability

Open EdColeman opened this issue 2 years ago • 1 comments

The convenience definitions that provide a Text object for constants in MetadataSchema expose the constants to changes if the Text object is mutated. For example:

 public static class ServerColumnFamily {
      public static final String STR_NAME = "srv";
      public static final Text NAME = new Text(STR_NAME);
...

Anything that uses ServerColumnFamily.NAME and then writes to that object will change the definition for everything using that ServerColumnFamily.NAME object,

Options:

  • If it is not a significant impact, could those convenience definitions of Text objects be removed?
  • Subclass the Text object in these cases to enforce immutability?
  • Use a immutable "byte-array" class instead of Text?

EdColeman avatar Oct 18 '23 16:10 EdColeman

  • Use a immutable "byte-array" class instead of Text?

This isn't really an option right now, because the reason these are Text is because they're using our client APIs to write rows and column data to the metadata, and those APIs use Text. So until those APIs support a different kind of immutable byte array type, then it doesn't make sense to consider it for these.

ctubbsii avatar Oct 20 '23 09:10 ctubbsii