docs: @Override
      public void onClose(Session session, CloseReason closeReason) {
          if (onClose != null) {
              Object args[] = new Object[onClose.getMethod().getParameterTypes().length];
              MethodData methodData = onClose.getMethodData();
              //check if method has optional Session parameter
              int sessionIndex = methodData.getSessionIndex();
              if (sessionIndex >= 0) {
                  args[sessionIndex] = session;
              }
              //check if method has optional closeReason parameter
              int reasonIndex = methodData.getCloseReasonIndex();
              if (reasonIndex >= 0) {
                  args[reasonIndex] = closeReason;
              }
              if (shouldProcessPath) {
                  try {
                      //substitute values for @PathParam values for this method.
                      onClose.processPathParameters(this, args);
                  } catch (DecodeException e) {
                      /*
                       * JSR 356 @PathParam section
                       * "If the container cannot decode the path segment appropriately to the annotated path parameter, then the container must raise an DecodeException to the error
                       * handling method of the websocket containing the path segment. [WSC-4.3-6]"
                       * Section
                       * 4.
                       * 5:"If the method itself throws an error, the implementation must pass this error to the onError() method of the endpoint together with the session [WSC-4.5-3]"
                       */
                      this.onError(session, e);
                      return;
                  }
              }
  
              try {
                  if (appInstance == null) {
                      if (tc.isDebugEnabled()) {
                          Tr.debug(tc, "application instance is null in onClose");
                      }
                      return;
                  }
  
                  onClose.getMethod().invoke(appInstance, args);
  
              } catch (IllegalAccessException e) {
                  //JSR 356 Section 4.5:  "If the method itself throws an error, the implementation
                  //must pass this error to the onError() method of the endpoint together with the session [WSC-4.5-3]"
                  this.onError(session, e);
              } catch (IllegalArgumentException e) {
                  this.onError(session, e);
              } catch (InvocationTargetException e) {
                  this.onError(session, e);
              }
          } else { //onClose method is not defined, hence log the problem in trace
              if (tc.isDebugEnabled()) {
                  Tr.debug(tc, "onClose() is called on Endpoint class: " + sepClass + " which does not have onClose method defined");
              }
          }
      }