private ResultCollector<Boolean, Collection<Boolean>> executeFunctionWithInstance(
      final Region region, final BooleanFunction function) {
    Execution<Void, Boolean, Collection<Boolean>> dataSet = FunctionService.onRegion(region);
    ResultCollector<Boolean, Collection<Boolean>> resultCollector = dataSet.execute(function);
    return resultCollector;
  }
TRAC #40714: Registering a function on a Java client changes the behavior when executing an
instance of the function

On a Java client if a function is registered with id="f1":

<pre>
FunctionService.registerFunction(new FunctionAdapter() {
  private final Integer state = 1;

  public String getId() {
    return "f1";
  }

  public void execute(FunctionContext fc) {}
});
</pre>

But execute a particular instance of a function e.g.:

<pre>
FunctionService.onRegion(r).execute(new FunctionAdapter() {
  private final Integer state = 2;

  public String getId() {
    return "f1";
  }

  public void execute(FunctionContext fc) {}
});
</pre>

The execution code does not serialize (nor execute) the instance which was given. The problems
are:
<ul>

<li>Confusing behavior, the programmer intended an instance (and its state) to be serialized and
executed.</li>

<li>Assumes that a function with the same Id is registered on the server which is not necessarily
the case.</li>

</ul>

<p>
Extracted from {@link PRFunctionExecutionDUnitTest}.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/ExecuteFunctionInstanceRegressionTest.java