This is an automated email from the ASF dual-hosted git repository.

rickyma pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git


The following commit(s) were added to refs/heads/master by this push:
     new 1482804f3 [#1668] fix: Replace assertions with exception-throwing 
codes (#1804)
1482804f3 is described below

commit 1482804f3bd365adce9af251a0a71ca463928083
Author: RickyMa <[email protected]>
AuthorDate: Mon Jun 24 11:01:48 2024 +0800

    [#1668] fix: Replace assertions with exception-throwing codes (#1804)
    
    ### What changes were proposed in this pull request?
    
    Replace assertions with exception-throwing codes to make them work in 
production.
    
    ### Why are the changes needed?
    
    For: https://github.com/apache/incubator-uniffle/issues/1668.
    This will make the exception checks work and make the code more reliable.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing UTs.
---
 .../apache/hadoop/mapreduce/task/reduce/RssEventFetcher.java  |  4 +++-
 .../org/apache/spark/shuffle/writer/RssShuffleWriter.java     |  5 ++++-
 .../org/apache/spark/shuffle/writer/RssShuffleWriter.java     |  5 ++++-
 .../src/main/java/org/apache/tez/common/RssTezUtils.java      |  5 ++++-
 .../library/common/shuffle/impl/RssShuffleManager.java        |  5 ++++-
 .../library/common/shuffle/impl/RssTezFetcherTask.java        |  6 +++++-
 .../common/shuffle/orderedgrouped/RssShuffleScheduler.java    |  4 +++-
 .../tez/runtime/library/input/RssOrderedGroupedKVInput.java   |  8 ++++++--
 .../apache/tez/runtime/library/input/RssUnorderedKVInput.java |  8 ++++++--
 .../runtime/library/output/RssOrderedPartitionedKVOutput.java |  9 +++++++--
 .../tez/runtime/library/output/RssUnorderedKVOutput.java      |  9 +++++++--
 .../library/output/RssUnorderedPartitionedKVOutput.java       |  9 +++++++--
 .../java/org/apache/uniffle/common/netty/MessageEncoder.java  |  5 ++++-
 .../apache/uniffle/common/netty/TransportFrameDecoder.java    |  5 ++++-
 .../uniffle/common/netty/client/TransportClientFactory.java   |  5 ++++-
 .../org/apache/uniffle/common/netty/protocol/Message.java     |  5 ++++-
 .../java/org/apache/uniffle/common/storage/StorageMedia.java  |  5 ++++-
 .../java/org/apache/uniffle/common/storage/StorageStatus.java |  5 ++++-
 .../uniffle/coordinator/web/resource/ServerResource.java      | 11 +++++++----
 .../main/java/org/apache/uniffle/server/ShuffleServer.java    |  7 ++++++-
 20 files changed, 97 insertions(+), 28 deletions(-)

diff --git 
a/client-mr/core/src/main/java/org/apache/hadoop/mapreduce/task/reduce/RssEventFetcher.java
 
b/client-mr/core/src/main/java/org/apache/hadoop/mapreduce/task/reduce/RssEventFetcher.java
index d2fdcdbac..9b86cabee 100644
--- 
a/client-mr/core/src/main/java/org/apache/hadoop/mapreduce/task/reduce/RssEventFetcher.java
+++ 
b/client-mr/core/src/main/java/org/apache/hadoop/mapreduce/task/reduce/RssEventFetcher.java
@@ -163,7 +163,9 @@ public class RssEventFetcher<K, V> {
         LOG.debug("Got " + events.length + " map completion events from " + 
fromEventIdx);
       }
 
-      assert !update.shouldReset() : "Unexpected legacy state";
+      if (update.shouldReset()) {
+        throw new RssException("Unexpected legacy state");
+      }
 
       // Update the last seen event ID
       fromEventIdx += events.length;
diff --git 
a/client-spark/spark2/src/main/java/org/apache/spark/shuffle/writer/RssShuffleWriter.java
 
b/client-spark/spark2/src/main/java/org/apache/spark/shuffle/writer/RssShuffleWriter.java
index ee552d325..65b66df3d 100644
--- 
a/client-spark/spark2/src/main/java/org/apache/spark/shuffle/writer/RssShuffleWriter.java
+++ 
b/client-spark/spark2/src/main/java/org/apache/spark/shuffle/writer/RssShuffleWriter.java
@@ -321,7 +321,10 @@ public class RssShuffleWriter<K, V, C> extends 
ShuffleWriter<K, V> {
     long expected = blockIds.size();
     long bufferManagerTracked = bufferManager.getBlockCount();
 
-    assert serverToPartitionToBlockIds != null;
+    if (serverToPartitionToBlockIds == null) {
+      throw new RssException("serverToPartitionToBlockIds should not be null");
+    }
+
     // to filter the multiple replica's duplicate blockIds
     Set<Long> blockIds = new HashSet<>();
     for (Map<Integer, Set<Long>> partitionBlockIds : 
serverToPartitionToBlockIds.values()) {
diff --git 
a/client-spark/spark3/src/main/java/org/apache/spark/shuffle/writer/RssShuffleWriter.java
 
b/client-spark/spark3/src/main/java/org/apache/spark/shuffle/writer/RssShuffleWriter.java
index 1d283cd94..3dfc2fd62 100644
--- 
a/client-spark/spark3/src/main/java/org/apache/spark/shuffle/writer/RssShuffleWriter.java
+++ 
b/client-spark/spark3/src/main/java/org/apache/spark/shuffle/writer/RssShuffleWriter.java
@@ -368,7 +368,10 @@ public class RssShuffleWriter<K, V, C> extends 
ShuffleWriter<K, V> {
     long expected = blockIds.size();
     long bufferManagerTracked = bufferManager.getBlockCount();
 
-    assert serverToPartitionToBlockIds != null;
+    if (serverToPartitionToBlockIds == null) {
+      throw new RssException("serverToPartitionToBlockIds should not be null");
+    }
+
     // to filter the multiple replica's duplicate blockIds
     Set<Long> blockIds = new HashSet<>();
     for (Map<Integer, Set<Long>> partitionBlockIds : 
serverToPartitionToBlockIds.values()) {
diff --git a/client-tez/src/main/java/org/apache/tez/common/RssTezUtils.java 
b/client-tez/src/main/java/org/apache/tez/common/RssTezUtils.java
index c9a762fa9..e168ec0d3 100644
--- a/client-tez/src/main/java/org/apache/tez/common/RssTezUtils.java
+++ b/client-tez/src/main/java/org/apache/tez/common/RssTezUtils.java
@@ -362,7 +362,10 @@ public class RssTezUtils {
           new ShuffleServerInfo(info[0].split(":")[0], 
Integer.parseInt(info[0].split(":")[1]));
 
       String[] partitions = info[1].split("_");
-      assert (partitions.length > 0);
+
+      if (partitions.length <= 0) {
+        throw new RssException("The length of partitions should not be less 
than 0");
+      }
       for (String partitionId : partitions) {
         rssWorker.computeIfAbsent(Integer.parseInt(partitionId), k -> new 
HashSet<>());
         rssWorker.get(Integer.parseInt(partitionId)).add(serverInfo);
diff --git 
a/client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssShuffleManager.java
 
b/client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssShuffleManager.java
index 311d09f68..4fa7a7b98 100644
--- 
a/client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssShuffleManager.java
+++ 
b/client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssShuffleManager.java
@@ -99,6 +99,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.uniffle.common.ShuffleServerInfo;
+import org.apache.uniffle.common.exception.RssException;
 import org.apache.uniffle.common.util.JavaUtils;
 
 // This only knows how to deal with a single srcIndex for a given targetIndex.
@@ -1109,7 +1110,9 @@ public class RssShuffleManager extends ShuffleManager {
       shuffleInfoEventsMap.put(inputIdentifier, eventInfo);
     }
 
-    assert (eventInfo != null);
+    if (eventInfo == null) {
+      throw new RssException("eventInfo should not be null");
+    }
     eventInfo.spillProcessed(srcAttemptIdentifier.getSpillEventId());
     numFetchedSpills.getAndIncrement();
 
diff --git 
a/client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssTezFetcherTask.java
 
b/client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssTezFetcherTask.java
index f1dd85b8b..63922eb64 100644
--- 
a/client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssTezFetcherTask.java
+++ 
b/client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/impl/RssTezFetcherTask.java
@@ -24,6 +24,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.tez.common.CallableWithNdc;
@@ -44,6 +45,7 @@ import org.apache.uniffle.client.api.ShuffleWriteClient;
 import org.apache.uniffle.client.factory.ShuffleClientFactory;
 import org.apache.uniffle.common.RemoteStorageInfo;
 import org.apache.uniffle.common.ShuffleServerInfo;
+import org.apache.uniffle.common.exception.RssException;
 import org.apache.uniffle.common.util.UnitConverter;
 
 public class RssTezFetcherTask extends CallableWithNdc<FetchResult> {
@@ -89,7 +91,9 @@ public class RssTezFetcherTask extends 
CallableWithNdc<FetchResult> {
       Map<Integer, Roaring64NavigableMap> rssSuccessBlockIdBitmapMap,
       int numPhysicalInputs,
       int partitionNum) {
-    assert (inputs != null && inputs.size() > 0);
+    if (CollectionUtils.isEmpty(inputs)) {
+      throw new RssException("inputs should not be empty");
+    }
     this.fetcherCallback = fetcherCallback;
     this.inputContext = inputContext;
     this.conf = conf;
diff --git 
a/client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/RssShuffleScheduler.java
 
b/client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/RssShuffleScheduler.java
index 07e0f9021..8fb873649 100644
--- 
a/client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/RssShuffleScheduler.java
+++ 
b/client-tez/src/main/java/org/apache/tez/runtime/library/common/shuffle/orderedgrouped/RssShuffleScheduler.java
@@ -804,7 +804,9 @@ class RssShuffleScheduler extends ShuffleScheduler {
           pipelinedShuffleInfoEventsMap.put(inputIdentifier, eventInfo);
         }
 
-        assert (eventInfo != null);
+        if (eventInfo == null) {
+          throw new RssException("eventInfo should not be null");
+        }
         eventInfo.spillProcessed(srcAttemptIdentifier.getSpillEventId());
         numFetchedSpills++;
 
diff --git 
a/client-tez/src/main/java/org/apache/tez/runtime/library/input/RssOrderedGroupedKVInput.java
 
b/client-tez/src/main/java/org/apache/tez/runtime/library/input/RssOrderedGroupedKVInput.java
index 3fe1cf3be..faa03fff3 100644
--- 
a/client-tez/src/main/java/org/apache/tez/runtime/library/input/RssOrderedGroupedKVInput.java
+++ 
b/client-tez/src/main/java/org/apache/tez/runtime/library/input/RssOrderedGroupedKVInput.java
@@ -136,8 +136,12 @@ public class RssOrderedGroupedKVInput extends 
AbstractLogicalInput {
     TezDAGID tezDAGID = tezVertexID.getDAGId();
     int sourceVertexId = this.conf.getInt(RSS_SHUFFLE_SOURCE_VERTEX_ID, -1);
     int destinationVertexId = 
this.conf.getInt(RSS_SHUFFLE_DESTINATION_VERTEX_ID, -1);
-    assert sourceVertexId != -1;
-    assert destinationVertexId != -1;
+    if (sourceVertexId == -1) {
+      throw new RssException("sourceVertexId should not be -1");
+    }
+    if (destinationVertexId == -1) {
+      throw new RssException("destinationVertexId should not be -1");
+    }
     this.shuffleId =
         RssTezUtils.computeShuffleId(tezDAGID.getId(), sourceVertexId, 
destinationVertexId);
     this.applicationAttemptId =
diff --git 
a/client-tez/src/main/java/org/apache/tez/runtime/library/input/RssUnorderedKVInput.java
 
b/client-tez/src/main/java/org/apache/tez/runtime/library/input/RssUnorderedKVInput.java
index f9d03c712..b328a98be 100644
--- 
a/client-tez/src/main/java/org/apache/tez/runtime/library/input/RssUnorderedKVInput.java
+++ 
b/client-tez/src/main/java/org/apache/tez/runtime/library/input/RssUnorderedKVInput.java
@@ -130,8 +130,12 @@ public class RssUnorderedKVInput extends 
AbstractLogicalInput {
     TezDAGID tezDAGID = tezVertexID.getDAGId();
     int sourceVertexId = this.conf.getInt(RSS_SHUFFLE_SOURCE_VERTEX_ID, -1);
     int destinationVertexId = 
this.conf.getInt(RSS_SHUFFLE_DESTINATION_VERTEX_ID, -1);
-    assert sourceVertexId != -1;
-    assert destinationVertexId != -1;
+    if (sourceVertexId == -1) {
+      throw new RssException("sourceVertexId should not be -1");
+    }
+    if (destinationVertexId == -1) {
+      throw new RssException("destinationVertexId should not be -1");
+    }
     this.shuffleId =
         RssTezUtils.computeShuffleId(tezDAGID.getId(), sourceVertexId, 
destinationVertexId);
     this.applicationAttemptId =
diff --git 
a/client-tez/src/main/java/org/apache/tez/runtime/library/output/RssOrderedPartitionedKVOutput.java
 
b/client-tez/src/main/java/org/apache/tez/runtime/library/output/RssOrderedPartitionedKVOutput.java
index fc163e90f..6bf563c9a 100644
--- 
a/client-tez/src/main/java/org/apache/tez/runtime/library/output/RssOrderedPartitionedKVOutput.java
+++ 
b/client-tez/src/main/java/org/apache/tez/runtime/library/output/RssOrderedPartitionedKVOutput.java
@@ -68,6 +68,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.uniffle.common.ShuffleServerInfo;
+import org.apache.uniffle.common.exception.RssException;
 
 import static 
org.apache.tez.common.RssTezConfig.RSS_AM_SHUFFLE_MANAGER_ADDRESS;
 import static org.apache.tez.common.RssTezConfig.RSS_AM_SHUFFLE_MANAGER_PORT;
@@ -166,8 +167,12 @@ public class RssOrderedPartitionedKVOutput extends 
AbstractLogicalOutput {
     TezDAGID tezDAGID = tezVertexID.getDAGId();
     int sourceVertexId = this.conf.getInt(RSS_SHUFFLE_SOURCE_VERTEX_ID, -1);
     int destinationVertexId = 
this.conf.getInt(RSS_SHUFFLE_DESTINATION_VERTEX_ID, -1);
-    assert sourceVertexId != -1;
-    assert destinationVertexId != -1;
+    if (sourceVertexId == -1) {
+      throw new RssException("sourceVertexId should not be -1");
+    }
+    if (destinationVertexId == -1) {
+      throw new RssException("destinationVertexId should not be -1");
+    }
     this.shuffleId =
         RssTezUtils.computeShuffleId(tezDAGID.getId(), sourceVertexId, 
destinationVertexId);
     GetShuffleServerRequest request =
diff --git 
a/client-tez/src/main/java/org/apache/tez/runtime/library/output/RssUnorderedKVOutput.java
 
b/client-tez/src/main/java/org/apache/tez/runtime/library/output/RssUnorderedKVOutput.java
index 39cfc4693..6aa32b327 100644
--- 
a/client-tez/src/main/java/org/apache/tez/runtime/library/output/RssUnorderedKVOutput.java
+++ 
b/client-tez/src/main/java/org/apache/tez/runtime/library/output/RssUnorderedKVOutput.java
@@ -68,6 +68,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.uniffle.common.ShuffleServerInfo;
+import org.apache.uniffle.common.exception.RssException;
 
 import static 
org.apache.tez.common.RssTezConfig.RSS_AM_SHUFFLE_MANAGER_ADDRESS;
 import static org.apache.tez.common.RssTezConfig.RSS_AM_SHUFFLE_MANAGER_PORT;
@@ -166,8 +167,12 @@ public class RssUnorderedKVOutput extends 
AbstractLogicalOutput {
     TezDAGID tezDAGID = tezVertexID.getDAGId();
     int sourceVertexId = this.conf.getInt(RSS_SHUFFLE_SOURCE_VERTEX_ID, -1);
     int destinationVertexId = 
this.conf.getInt(RSS_SHUFFLE_DESTINATION_VERTEX_ID, -1);
-    assert sourceVertexId != -1;
-    assert destinationVertexId != -1;
+    if (sourceVertexId == -1) {
+      throw new RssException("sourceVertexId should not be -1");
+    }
+    if (destinationVertexId == -1) {
+      throw new RssException("destinationVertexId should not be -1");
+    }
     this.shuffleId =
         RssTezUtils.computeShuffleId(tezDAGID.getId(), sourceVertexId, 
destinationVertexId);
     this.applicationAttemptId =
diff --git 
a/client-tez/src/main/java/org/apache/tez/runtime/library/output/RssUnorderedPartitionedKVOutput.java
 
b/client-tez/src/main/java/org/apache/tez/runtime/library/output/RssUnorderedPartitionedKVOutput.java
index ef73b640b..bc78a2f67 100644
--- 
a/client-tez/src/main/java/org/apache/tez/runtime/library/output/RssUnorderedPartitionedKVOutput.java
+++ 
b/client-tez/src/main/java/org/apache/tez/runtime/library/output/RssUnorderedPartitionedKVOutput.java
@@ -68,6 +68,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.uniffle.common.ShuffleServerInfo;
+import org.apache.uniffle.common.exception.RssException;
 
 import static 
org.apache.tez.common.RssTezConfig.RSS_AM_SHUFFLE_MANAGER_ADDRESS;
 import static org.apache.tez.common.RssTezConfig.RSS_AM_SHUFFLE_MANAGER_PORT;
@@ -164,8 +165,12 @@ public class RssUnorderedPartitionedKVOutput extends 
AbstractLogicalOutput {
     TezDAGID tezDAGID = tezVertexID.getDAGId();
     int sourceVertexId = this.conf.getInt(RSS_SHUFFLE_SOURCE_VERTEX_ID, -1);
     int destinationVertexId = 
this.conf.getInt(RSS_SHUFFLE_DESTINATION_VERTEX_ID, -1);
-    assert sourceVertexId != -1;
-    assert destinationVertexId != -1;
+    if (sourceVertexId == -1) {
+      throw new RssException("sourceVertexId should not be -1");
+    }
+    if (destinationVertexId == -1) {
+      throw new RssException("destinationVertexId should not be -1");
+    }
     this.shuffleId =
         RssTezUtils.computeShuffleId(tezDAGID.getId(), sourceVertexId, 
destinationVertexId);
     this.applicationAttemptId =
diff --git 
a/common/src/main/java/org/apache/uniffle/common/netty/MessageEncoder.java 
b/common/src/main/java/org/apache/uniffle/common/netty/MessageEncoder.java
index d2947b3bc..cd4002482 100644
--- a/common/src/main/java/org/apache/uniffle/common/netty/MessageEncoder.java
+++ b/common/src/main/java/org/apache/uniffle/common/netty/MessageEncoder.java
@@ -26,6 +26,7 @@ import io.netty.handler.codec.MessageToMessageEncoder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.uniffle.common.exception.RssException;
 import org.apache.uniffle.common.netty.protocol.Message;
 import org.apache.uniffle.common.netty.protocol.MessageWithHeader;
 import org.apache.uniffle.common.netty.protocol.RpcResponse;
@@ -84,7 +85,9 @@ public final class MessageEncoder extends 
MessageToMessageEncoder<Message> {
     msgType.encode(header);
     header.writeInt(bodyLength);
     in.encode(header);
-    assert header.writableBytes() == 0;
+    if (header.writableBytes() != 0) {
+      throw new RssException("header's writable bytes should be 0");
+    }
 
     if (body != null) {
       // We transfer ownership of the reference on in.body() to 
MessageWithHeader.
diff --git 
a/common/src/main/java/org/apache/uniffle/common/netty/TransportFrameDecoder.java
 
b/common/src/main/java/org/apache/uniffle/common/netty/TransportFrameDecoder.java
index 3b6186d35..a0aef7d1a 100644
--- 
a/common/src/main/java/org/apache/uniffle/common/netty/TransportFrameDecoder.java
+++ 
b/common/src/main/java/org/apache/uniffle/common/netty/TransportFrameDecoder.java
@@ -28,6 +28,7 @@ import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
 
+import org.apache.uniffle.common.exception.RssException;
 import org.apache.uniffle.common.netty.protocol.Message;
 
 /**
@@ -160,7 +161,9 @@ public class TransportFrameDecoder extends 
ChannelInboundHandlerAdapter implemen
       remaining -= next.readableBytes();
       frame.addComponent(next).writerIndex(frame.writerIndex() + 
next.readableBytes());
     }
-    assert remaining == 0;
+    if (remaining != 0) {
+      throw new RssException("The remaining should be 0");
+    }
     return frame;
   }
 
diff --git 
a/common/src/main/java/org/apache/uniffle/common/netty/client/TransportClientFactory.java
 
b/common/src/main/java/org/apache/uniffle/common/netty/client/TransportClientFactory.java
index 4108b486b..a87611ed3 100644
--- 
a/common/src/main/java/org/apache/uniffle/common/netty/client/TransportClientFactory.java
+++ 
b/common/src/main/java/org/apache/uniffle/common/netty/client/TransportClientFactory.java
@@ -38,6 +38,7 @@ import io.netty.channel.socket.SocketChannel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.uniffle.common.exception.RssException;
 import org.apache.uniffle.common.netty.IOMode;
 import org.apache.uniffle.common.netty.TransportFrameDecoder;
 import org.apache.uniffle.common.netty.handle.TransportChannelHandler;
@@ -233,7 +234,9 @@ public class TransportClientFactory implements Closeable {
     }
 
     TransportClient client = clientRef.get();
-    assert client != null : "Channel future completed successfully with null 
client";
+    if (client == null) {
+      throw new RssException("Channel future completed unsuccessfully with 
null client");
+    }
 
     if (logger.isDebugEnabled()) {
       logger.debug("Connection to {} successful", address);
diff --git 
a/common/src/main/java/org/apache/uniffle/common/netty/protocol/Message.java 
b/common/src/main/java/org/apache/uniffle/common/netty/protocol/Message.java
index e941a8d1b..8e925fac8 100644
--- a/common/src/main/java/org/apache/uniffle/common/netty/protocol/Message.java
+++ b/common/src/main/java/org/apache/uniffle/common/netty/protocol/Message.java
@@ -19,6 +19,7 @@ package org.apache.uniffle.common.netty.protocol;
 
 import io.netty.buffer.ByteBuf;
 
+import org.apache.uniffle.common.exception.RssException;
 import org.apache.uniffle.common.netty.buffer.ManagedBuffer;
 
 public abstract class Message implements Encodable {
@@ -66,7 +67,9 @@ public abstract class Message implements Encodable {
     private final byte id;
 
     Type(int id) {
-      assert id < 128 : "Cannot have more than 128 message types";
+      if (id >= 128) {
+        throw new RssException("Cannot have more than 128 message types");
+      }
       this.id = (byte) id;
     }
 
diff --git 
a/common/src/main/java/org/apache/uniffle/common/storage/StorageMedia.java 
b/common/src/main/java/org/apache/uniffle/common/storage/StorageMedia.java
index 85f550f26..27acf686a 100644
--- a/common/src/main/java/org/apache/uniffle/common/storage/StorageMedia.java
+++ b/common/src/main/java/org/apache/uniffle/common/storage/StorageMedia.java
@@ -17,6 +17,7 @@
 
 package org.apache.uniffle.common.storage;
 
+import org.apache.uniffle.common.exception.RssException;
 import org.apache.uniffle.proto.RssProtos.StorageInfo;
 
 public enum StorageMedia {
@@ -29,7 +30,9 @@ public enum StorageMedia {
   private final byte val;
 
   StorageMedia(int code) {
-    assert (code >= -1 && code < 256);
+    if (code < -1 || code >= 256) {
+      throw new RssException("The code should be within [-1, 256)");
+    }
     this.val = (byte) code;
   }
 
diff --git 
a/common/src/main/java/org/apache/uniffle/common/storage/StorageStatus.java 
b/common/src/main/java/org/apache/uniffle/common/storage/StorageStatus.java
index e69a768e7..75fdc47e3 100644
--- a/common/src/main/java/org/apache/uniffle/common/storage/StorageStatus.java
+++ b/common/src/main/java/org/apache/uniffle/common/storage/StorageStatus.java
@@ -17,6 +17,7 @@
 
 package org.apache.uniffle.common.storage;
 
+import org.apache.uniffle.common.exception.RssException;
 import org.apache.uniffle.proto.RssProtos.StorageInfo;
 
 public enum StorageStatus {
@@ -28,7 +29,9 @@ public enum StorageStatus {
   private final byte val;
 
   StorageStatus(int code) {
-    assert (code >= -1 && code < 256);
+    if (code < -1 || code >= 256) {
+      throw new RssException("The code should be within [-1, 256)");
+    }
     this.val = (byte) code;
   }
 
diff --git 
a/coordinator/src/main/java/org/apache/uniffle/coordinator/web/resource/ServerResource.java
 
b/coordinator/src/main/java/org/apache/uniffle/coordinator/web/resource/ServerResource.java
index d78796adf..c5191d535 100644
--- 
a/coordinator/src/main/java/org/apache/uniffle/coordinator/web/resource/ServerResource.java
+++ 
b/coordinator/src/main/java/org/apache/uniffle/coordinator/web/resource/ServerResource.java
@@ -39,6 +39,7 @@ import org.apache.hbase.thirdparty.javax.ws.rs.core.MediaType;
 
 import org.apache.uniffle.common.Application;
 import org.apache.uniffle.common.ServerStatus;
+import org.apache.uniffle.common.exception.RssException;
 import org.apache.uniffle.common.web.resource.BaseResource;
 import org.apache.uniffle.common.web.resource.Response;
 import org.apache.uniffle.coordinator.ApplicationManager;
@@ -100,8 +101,9 @@ public class ServerResource extends BaseResource {
   public Response<Object> cancelDecommission(CancelDecommissionRequest params) 
{
     return execute(
         () -> {
-          assert CollectionUtils.isNotEmpty(params.getServerIds())
-              : "Parameter[serverIds] should not be null!";
+          if (CollectionUtils.isEmpty(params.getServerIds())) {
+            throw new RssException("Parameter[serverIds] should not be 
empty!");
+          }
           
params.getServerIds().forEach(getClusterManager()::cancelDecommission);
           return null;
         });
@@ -122,8 +124,9 @@ public class ServerResource extends BaseResource {
   public Response<Object> decommission(DecommissionRequest params) {
     return execute(
         () -> {
-          assert CollectionUtils.isNotEmpty(params.getServerIds())
-              : "Parameter[serverIds] should not be null!";
+          if (CollectionUtils.isEmpty(params.getServerIds())) {
+            throw new RssException("Parameter[serverIds] should not be 
empty!");
+          }
           params.getServerIds().forEach(getClusterManager()::decommission);
           return null;
         });
diff --git a/server/src/main/java/org/apache/uniffle/server/ShuffleServer.java 
b/server/src/main/java/org/apache/uniffle/server/ShuffleServer.java
index de874816a..7340fe3b3 100644
--- a/server/src/main/java/org/apache/uniffle/server/ShuffleServer.java
+++ b/server/src/main/java/org/apache/uniffle/server/ShuffleServer.java
@@ -284,7 +284,12 @@ public class ShuffleServer {
     nettyServerEnabled =
         shuffleServerConf.get(ShuffleServerConf.RPC_SERVER_TYPE) == 
ServerType.GRPC_NETTY;
     if (nettyServerEnabled) {
-      assert nettyPort >= 0;
+      if (nettyPort < 0) {
+        throw new RssException(
+            String.format(
+                "%s must be set during startup when using GRPC_NETTY",
+                ShuffleServerConf.NETTY_SERVER_PORT.key()));
+      }
       streamServer = new StreamServer(this);
     }
 

Reply via email to