This is an automated email from the ASF dual-hosted git repository.
pradeep pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push:
new bb84319c0 Revert "RANGER-5397: IllegalArgumentException in
RangerRESTClient when no ran…" (#778)
bb84319c0 is described below
commit bb84319c088fa9476d85d87e7d7a2b5611a0bc5c
Author: PradeeP AgrawaL <[email protected]>
AuthorDate: Wed Dec 31 13:37:39 2025 +0530
Revert "RANGER-5397: IllegalArgumentException in RangerRESTClient when no
ran…" (#778)
This reverts commit 464bfd95efa37984a0274bcdf7c0332330f4cc57.
---
.../ranger/plugin/util/RangerRESTClient.java | 8 ++--
.../ranger/plugin/util/TestRangerRESTClient.java | 50 ----------------------
2 files changed, 3 insertions(+), 55 deletions(-)
diff --git
a/agents-common/src/main/java/org/apache/ranger/plugin/util/RangerRESTClient.java
b/agents-common/src/main/java/org/apache/ranger/plugin/util/RangerRESTClient.java
index da1e0eee9..447ddd90b 100644
---
a/agents-common/src/main/java/org/apache/ranger/plugin/util/RangerRESTClient.java
+++
b/agents-common/src/main/java/org/apache/ranger/plugin/util/RangerRESTClient.java
@@ -110,11 +110,9 @@ public RangerRESTClient(String url, String
sslConfigFileName, Configuration conf
mUrl = url;
mSslConfigFileName = sslConfigFileName;
configuredURLs = StringUtil.getURLs(mUrl);
- if (StringUtil.isEmpty(url)) {
- throw new IllegalArgumentException("Ranger URL is null or empty.
Likely caused by incorrect configuration");
- } else {
- setLastKnownActiveUrlIndex((new
Random()).nextInt(getConfiguredURLs().size()));
- }
+
+ setLastKnownActiveUrlIndex((new
Random()).nextInt(getConfiguredURLs().size()));
+
init(config);
}
diff --git
a/agents-common/src/test/java/org/apache/ranger/plugin/util/TestRangerRESTClient.java
b/agents-common/src/test/java/org/apache/ranger/plugin/util/TestRangerRESTClient.java
deleted file mode 100644
index 0e5d34e04..000000000
---
a/agents-common/src/test/java/org/apache/ranger/plugin/util/TestRangerRESTClient.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.ranger.plugin.util;
-
-import org.apache.ranger.authorization.hadoop.config.RangerPluginConfig;
-import org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions;
-import org.apache.ranger.plugin.service.RangerBasePlugin;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TestRangerRESTClient {
- private static final String SERVICE_TYPE = "hive";
- private static final String SERVICE_NAME = "test-service";
- private static final String APP_ID = "test-app";
- private static final String ERR_MESSAGE = "Ranger URL is null or empty.";
-
- @Test
- public void testPluginInit_WithNoUrl_ThrowsException() {
- RangerBasePlugin plugin = new RangerBasePlugin(SERVICE_TYPE,
SERVICE_NAME, APP_ID);
- IllegalArgumentException exception =
Assert.assertThrows(IllegalArgumentException.class, plugin::init);
- Assert.assertTrue(exception.getMessage().contains(ERR_MESSAGE));
- }
-
- @Test
- public void testPluginInit_WithValidUrl_Succeeds() {
- RangerPolicyEngineOptions peOptions = new RangerPolicyEngineOptions();
- RangerPluginConfig pluginConfig = new RangerPluginConfig(SERVICE_TYPE,
SERVICE_NAME, APP_ID, "cl1", "on-perm", peOptions);
- pluginConfig.set("ranger.plugin.hive.policy.rest.url",
"http://dummy:1234");
- RangerBasePlugin plugin = new RangerBasePlugin(pluginConfig);
- plugin.init();
- Assert.assertNotNull("RangerBasePlugin should be initialized
successfully", plugin);
- }
-}