THRIFT-5762 Fix spotless errors

Run `gradlew :spotlessApply` to apply the correct coding style.

Update kotlin compiler to support `getEmptyResultInstance`

https://github.com/apache/thrift/pull/2939 added the feature to create
an instance of the result object without having to use the
ProcessFunction.
The Kotlin compiler re-uses the java lib so this commit udpates the
Kotlin compiler to support this feature as well.
diff --git a/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc b/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc
index a017272..78917d9 100644
--- a/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_kotlin_generator.cc
@@ -1615,7 +1615,7 @@
                  "org.apache.thrift.AsyncProcessFunction<"
               << tservice->get_name()
               << ", out org.apache.thrift.TBase<*, "
-                 "*>, out kotlin.Any>> = mapOf("
+                 "*>, out kotlin.Any, out org.apache.thrift.TBase<*, *>>> = mapOf("
               << endl;
   indent_up();
   {
@@ -1656,16 +1656,27 @@
                                                            t_function* tfunc) {
   string args_name = tservice->get_name() + "FunctionArgs." + tfunc->get_name() + "_args";
   string rtype = type_name(tfunc->get_returntype(), true);
+  string resultname = tservice->get_name() + "FunctionResult." + tfunc->get_name() + "_result";
 
   indent(out) << "class " << tfunc->get_name() << "<I : " << tservice->get_name()
               << ">(private val scope: kotlinx.coroutines.CoroutineScope) : "
                  "org.apache.thrift.AsyncProcessFunction<I, "
-              << args_name << ", " << rtype << ">(\"" << tfunc->get_name()
-              << "\"), ProcessFunction {" << endl;
+              << args_name << ", " << rtype << ", "
+              << (tfunc->is_oneway() ? "org.apache.thrift.TBase<*, *>" : resultname)
+              << ">(\"" << tfunc->get_name() << "\"), ProcessFunction {" 
+              << endl;
   indent_up();
   {
     indent(out) << "override fun isOneway() = " << (tfunc->is_oneway() ? "true" : "false") << endl;
     indent(out) << "override fun getEmptyArgsInstance() = " << args_name << "()" << endl;
+    indent(out) << "override fun getEmptyResultInstance() = ";
+    if (tfunc->is_oneway()) {
+      out << "null" << endl;
+    }
+    else {
+      out << resultname << "()" << endl;
+    }
+    indent(out) << endl;
     indent(out) << "override fun start(iface: I, args: " << args_name
                 << ", resultHandler: org.apache.thrift.async.AsyncMethodCallback<" << rtype
                 << ">) {" << endl;
diff --git a/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java b/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java
index 8552863..ac99d8e 100644
--- a/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java
+++ b/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java
@@ -9,90 +9,88 @@
 import org.slf4j.LoggerFactory;
 
 public abstract class ProcessFunction<I, T extends TBase, A extends TBase> {
-    private final String methodName;
+  private final String methodName;
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(ProcessFunction.class.getName());
+  private static final Logger LOGGER = LoggerFactory.getLogger(ProcessFunction.class.getName());
 
-    public ProcessFunction(String methodName) {
-        this.methodName = methodName;
+  public ProcessFunction(String methodName) {
+    this.methodName = methodName;
+  }
+
+  public final void process(int seqid, TProtocol iprot, TProtocol oprot, I iface)
+      throws TException {
+    T args = getEmptyArgsInstance();
+    try {
+      args.read(iprot);
+    } catch (TProtocolException e) {
+      iprot.readMessageEnd();
+      TApplicationException x =
+          new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());
+      oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid));
+      x.write(oprot);
+      oprot.writeMessageEnd();
+      oprot.getTransport().flush();
+      return;
+    }
+    iprot.readMessageEnd();
+    TSerializable result = null;
+    byte msgType = TMessageType.REPLY;
+
+    try {
+      result = getResult(iface, args);
+    } catch (TTransportException ex) {
+      LOGGER.error("Transport error while processing " + getMethodName(), ex);
+      throw ex;
+    } catch (TApplicationException ex) {
+      LOGGER.error("Internal application error processing " + getMethodName(), ex);
+      result = ex;
+      msgType = TMessageType.EXCEPTION;
+    } catch (Exception ex) {
+      LOGGER.error("Internal error processing " + getMethodName(), ex);
+      if (rethrowUnhandledExceptions()) throw new RuntimeException(ex.getMessage(), ex);
+      if (!isOneway()) {
+        result =
+            new TApplicationException(
+                TApplicationException.INTERNAL_ERROR,
+                "Internal error processing " + getMethodName());
+        msgType = TMessageType.EXCEPTION;
+      }
     }
 
-    public final void process(int seqid, TProtocol iprot, TProtocol oprot, I iface)
-            throws TException {
-        T args = getEmptyArgsInstance();
-        try {
-            args.read(iprot);
-        } catch (TProtocolException e) {
-            iprot.readMessageEnd();
-            TApplicationException x =
-                    new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());
-            oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid));
-            x.write(oprot);
-            oprot.writeMessageEnd();
-            oprot.getTransport().flush();
-            return;
-        }
-        iprot.readMessageEnd();
-        TSerializable result = null;
-        byte msgType = TMessageType.REPLY;
-
-        try {
-            result = getResult(iface, args);
-        } catch (TTransportException ex) {
-            LOGGER.error("Transport error while processing " + getMethodName(), ex);
-            throw ex;
-        } catch (TApplicationException ex) {
-            LOGGER.error("Internal application error processing " + getMethodName(), ex);
-            result = ex;
-            msgType = TMessageType.EXCEPTION;
-        } catch (Exception ex) {
-            LOGGER.error("Internal error processing " + getMethodName(), ex);
-            if (rethrowUnhandledExceptions()) throw new RuntimeException(ex.getMessage(), ex);
-            if (!isOneway()) {
-                result =
-                        new TApplicationException(
-                                TApplicationException.INTERNAL_ERROR,
-                                "Internal error processing " + getMethodName());
-                msgType = TMessageType.EXCEPTION;
-            }
-        }
-
-        if (!isOneway()) {
-            oprot.writeMessageBegin(new TMessage(getMethodName(), msgType, seqid));
-            result.write(oprot);
-            oprot.writeMessageEnd();
-            oprot.getTransport().flush();
-        }
+    if (!isOneway()) {
+      oprot.writeMessageBegin(new TMessage(getMethodName(), msgType, seqid));
+      result.write(oprot);
+      oprot.writeMessageEnd();
+      oprot.getTransport().flush();
     }
+  }
 
-    private void handleException(int seqid, TProtocol oprot) throws TException {
-        if (!isOneway()) {
-            TApplicationException x =
-                    new TApplicationException(
-                            TApplicationException.INTERNAL_ERROR, "Internal error processing " + getMethodName());
-            oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid));
-            x.write(oprot);
-            oprot.writeMessageEnd();
-            oprot.getTransport().flush();
-        }
+  private void handleException(int seqid, TProtocol oprot) throws TException {
+    if (!isOneway()) {
+      TApplicationException x =
+          new TApplicationException(
+              TApplicationException.INTERNAL_ERROR, "Internal error processing " + getMethodName());
+      oprot.writeMessageBegin(new TMessage(getMethodName(), TMessageType.EXCEPTION, seqid));
+      x.write(oprot);
+      oprot.writeMessageEnd();
+      oprot.getTransport().flush();
     }
+  }
 
-    protected boolean rethrowUnhandledExceptions() {
-        return false;
-    }
+  protected boolean rethrowUnhandledExceptions() {
+    return false;
+  }
 
-    public abstract boolean isOneway();
+  public abstract boolean isOneway();
 
-    public abstract TBase<?, ?> getResult(I iface, T args) throws TException;
+  public abstract TBase<?, ?> getResult(I iface, T args) throws TException;
 
-    public abstract T getEmptyArgsInstance();
+  public abstract T getEmptyArgsInstance();
 
-    /**
-     * Returns null when this is a oneWay function.
-     */
-    public abstract A getEmptyResultInstance();
+  /** Returns null when this is a oneWay function. */
+  public abstract A getEmptyResultInstance();
 
-    public String getMethodName() {
-        return methodName;
-    }
+  public String getMethodName() {
+    return methodName;
+  }
 }
diff --git a/lib/java/src/main/java/org/apache/thrift/TBaseAsyncProcessor.java b/lib/java/src/main/java/org/apache/thrift/TBaseAsyncProcessor.java
index 0a583c0..eedb8cb 100644
--- a/lib/java/src/main/java/org/apache/thrift/TBaseAsyncProcessor.java
+++ b/lib/java/src/main/java/org/apache/thrift/TBaseAsyncProcessor.java
@@ -33,12 +33,14 @@
   final Map<String, AsyncProcessFunction<I, ? extends TBase, ?, ? extends TBase>> processMap;
 
   public TBaseAsyncProcessor(
-      I iface, Map<String, AsyncProcessFunction<I, ? extends TBase, ?, ? extends TBase>> processMap) {
+      I iface,
+      Map<String, AsyncProcessFunction<I, ? extends TBase, ?, ? extends TBase>> processMap) {
     this.iface = iface;
     this.processMap = processMap;
   }
 
-  public Map<String, AsyncProcessFunction<I, ? extends TBase, ?, ? extends TBase>> getProcessMapView() {
+  public Map<String, AsyncProcessFunction<I, ? extends TBase, ?, ? extends TBase>>
+      getProcessMapView() {
     return Collections.unmodifiableMap(processMap);
   }
 
diff --git a/lib/java/src/main/java/org/apache/thrift/TBaseProcessor.java b/lib/java/src/main/java/org/apache/thrift/TBaseProcessor.java
index ff1ccfc..2cd805f 100644
--- a/lib/java/src/main/java/org/apache/thrift/TBaseProcessor.java
+++ b/lib/java/src/main/java/org/apache/thrift/TBaseProcessor.java
@@ -13,7 +13,8 @@
   private final Map<String, ProcessFunction<I, ? extends TBase, ? extends TBase>> processMap;
 
   protected TBaseProcessor(
-      I iface, Map<String, ProcessFunction<I, ? extends TBase, ? extends TBase>> processFunctionMap) {
+      I iface,
+      Map<String, ProcessFunction<I, ? extends TBase, ? extends TBase>> processFunctionMap) {
     this.iface = iface;
     this.processMap = processFunctionMap;
   }