code: public static void tryCancel(Promise<?> p, InternalLogger logger) {
          if (!p.cancel(false) && logger != null) {
              Throwable err = p.cause();
              if (err == null) {
                  logger.warn("Failed to cancel promise because it has succeeded already: {}", p);
              } else {
                  logger.warn(
                          "Failed to cancel promise because it has failed already: {}, unnotified cause:",
                          p, err);
              }
          }
      }
docs: Try to cancel the {@link Promise} and log if {@code logger} is not {@code null} in case this fails.