@Test
  public void testCustomFilter() throws Exception {
    Filter baseFilter = new PrefixFilter("foo".getBytes());
    FilterProtos.Filter filterProto = ProtobufUtil.toFilter(baseFilter);
    String suffix = "" + System.currentTimeMillis() + allowFastReflectionFallthrough;
    String className = "CustomLoadedFilter" + suffix;
    filterProto = filterProto.toBuilder().setName(className).build();

    Configuration conf = HBaseConfiguration.create();
    HBaseTestingUtil testUtil = new HBaseTestingUtil();
    String dataTestDir = testUtil.getDataTestDir().toString();

    // First make sure the test bed is clean, delete any pre-existing class.
    // Below toComparator call is expected to fail because the comparator is not loaded now
    ClassLoaderTestHelper.deleteClass(className, dataTestDir, conf);
    try {
      Filter filter = ProtobufUtil.toFilter(filterProto);
      fail("expected to fail");
    } catch (DoNotRetryIOException e) {
      // do nothing, this is expected
    }

    // Write a jar to be loaded into the classloader
    String code = StringSubstitutor
      .replace(IOUtils.toString(getClass().getResourceAsStream("/CustomLoadedFilter.java.template"),
        Charset.defaultCharset()), Collections.singletonMap("suffix", suffix));
    ClassLoaderTestHelper.buildJar(dataTestDir, className, code,
      ClassLoaderTestHelper.localDirPath(conf));

    // Disallow fallthrough at first. We expect below to fail because the custom filter is not
    // available at initialization so not in the cache.
    ProtobufUtil.setAllowFastReflectionFallthrough(false);
    try {
      ProtobufUtil.toFilter(filterProto);
      fail("expected to fail");
    } catch (DoNotRetryIOException e) {
      // do nothing, this is expected
    }

    // Now the deserialization should pass with fallthrough enabled. This proves that custom
    // filters can work despite not being supported by cache.
    ProtobufUtil.setAllowFastReflectionFallthrough(true);
    ProtobufUtil.toFilter(filterProto);

  }
Test that we can load and deserialize custom filters. Good to have generally, but also proves
that this still works after HBASE-27276 despite not going through our fast function caches.
hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterSerialization.java