All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.server.resp.commands.Resp3Command Maven / Gradle / Ivy

There is a newer version: 15.1.4.Final
Show newest version
package org.infinispan.server.resp.commands;

import java.util.List;
import java.util.concurrent.CompletionException;
import java.util.concurrent.CompletionStage;

import org.infinispan.commons.CacheException;
import org.infinispan.server.resp.Resp3Handler;
import org.infinispan.server.resp.RespErrorUtil;
import org.infinispan.server.resp.RespRequestHandler;

import io.netty.channel.ChannelHandlerContext;

public interface Resp3Command {

   CompletionStage perform(Resp3Handler handler, ChannelHandlerContext ctx, List arguments);

   default CompletionStage handleException(Resp3Handler handler, Throwable t) {
      Throwable ex = t;
      if (t instanceof CompletionException) {
         ex = t.getCause();
      }
      if (ex instanceof CacheException) {
         ex = ex.getCause();
      }
      if (ex instanceof ClassCastException) {
         RespErrorUtil.wrongType(handler.allocator());
         return handler.myStage();
      }

      if (ex instanceof IndexOutOfBoundsException) {
         RespErrorUtil.indexOutOfRange(handler.allocator());
         return handler.myStage();
      }

      throw new RuntimeException(t);
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy