World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#8009] fix: prevent NPE in validate() when ModelVersionUpdatesRequest updates is null (#8021)
Joonseo Leef2528b1519a7
diff --git a/common/src/main/java/org/apache/gravitino/dto/requests/ModelVersionUpdatesRequest.java b/common/src/main/java/org/apache/gravitino/dto/requests/ModelVersionUpdatesRequest.javaindex 14e2675041..13ec1d07e3 100644--- a/common/src/main/java/org/apache/gravitino/dto/requests/ModelVersionUpdatesRequest.java+++ b/common/src/main/java/org/apache/gravitino/dto/requests/ModelVersionUpdatesRequest.java@@ -41,6 +41,10 @@ public class ModelVersionUpdatesRequest implements RESTRequest {/** {@inheritDoc} */@Overridepublic void validate() throws IllegalArgumentException {+ if (updates == null) {+ throw new IllegalArgumentException("updates cannot be null");+ }+updates.forEach(ModelVersionUpdateRequest::validate);}}diff --git a/common/src/test/java/org/apache/gravitino/dto/requests/TestModelVersionUpdatesRequest.java b/common/src/test/java/org/apache/gravitino/dto/requests/TestModelVersionUpdatesRequest.javanew file mode 100644index 0000000000..7fcf1c980f--- /dev/null+++ b/common/src/test/java/org/apache/gravitino/dto/requests/TestModelVersionUpdatesRequest.java@@ -0,0 +1,35 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */+package org.apache.gravitino.dto.requests;++import org.junit.jupiter.api.Assertions;+import org.junit.jupiter.api.Test;++public class TestModelVersionUpdatesRequest {++ @Test+ public void testModelVersionUpdatesRequestWithUpdatesNull() {+ ModelVersionUpdatesRequest modelVersionUpdatesRequest = new ModelVersionUpdatesRequest(null);++ Assertions.assertThrows(+ IllegalArgumentException.class,+ modelVersionUpdatesRequest::validate,+ "updates cannot be null");+ }+}