You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2018/12/21 15:13:10 UTC
[qpid-broker-j] 02/03: QPID-8259: [Broker-J] Fix handling of
requests for unsupported category
This is an automated email from the ASF dual-hosted git repository.
orudyy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git
commit 92d5fa590817a2aa69840d10bcb967b31a19e2ed
Author: Alex Rudyy <or...@apache.org>
AuthorDate: Fri Dec 21 14:50:13 2018 +0000
QPID-8259: [Broker-J] Fix handling of requests for unsupported category
---
.../latest/LatestManagementController.java | 20 ++++++++++++++++----
.../qpid/tests/http/rest/model/OperationTest.java | 21 +++++++++++++++++++++
2 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementController.java
index 18b457a..7a32153 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementController.java
@@ -92,6 +92,7 @@ public class LatestManagementController extends AbstractManagementController
private static final int DEFAULT_DEPTH = 0;
private static final int DEFAULT_OVERSIZE = 120;
+ private static final Class<? extends ConfiguredObject>[] EMPTY_HIERARCHY = new Class[0];
private final ConcurrentMap<ConfiguredObject<?>, ConfiguredObjectFinder> _configuredObjectFinders =
@@ -172,7 +173,7 @@ public class LatestManagementController extends AbstractManagementController
final ConfiguredObjectFinder finder = getConfiguredObjectFinder(root);
final String category = request.getCategory();
final Class<? extends ConfiguredObject> configuredClass = getRequestCategoryClass(category, root.getModel());
- final Class<? extends ConfiguredObject>[] hierarchy = finder.getHierarchy(configuredClass);
+ final Class<? extends ConfiguredObject>[] hierarchy = getHierarchy(finder, configuredClass);
return getManagementRequestType(request.getMethod(), category, request.getPath(), hierarchy);
}
@@ -239,7 +240,7 @@ public class LatestManagementController extends AbstractManagementController
if (hierarchy.size() > 1)
{
final ConfiguredObjectFinder finder = getConfiguredObjectFinder(root);
- theParent = finder.findObjectParentsFromPath(path, finder.getHierarchy(categoryClass), categoryClass);
+ theParent = finder.findObjectParentsFromPath(path, getHierarchy(finder, categoryClass), categoryClass);
}
final boolean isFullObjectURL = path.size() == hierarchy.size();
@@ -628,7 +629,7 @@ public class LatestManagementController extends AbstractManagementController
final ConfiguredObjectFinder finder = getConfiguredObjectFinder(root);
final Class<? extends ConfiguredObject> configuredClass = getRequestCategoryClass(category, root.getModel());
Collection<ConfiguredObject<?>> targetObjects =
- finder.findObjectsFromPath(path, finder.getHierarchy(configuredClass), true);
+ finder.findObjectsFromPath(path, getHierarchy(finder, configuredClass), true);
if (targetObjects == null)
{
@@ -641,6 +642,17 @@ public class LatestManagementController extends AbstractManagementController
return targetObjects;
}
+ private Class<? extends ConfiguredObject>[] getHierarchy(final ConfiguredObjectFinder finder,
+ final Class<? extends ConfiguredObject> configuredClass)
+ {
+ final Class<? extends ConfiguredObject>[] hierarchy = finder.getHierarchy(configuredClass);
+ if (hierarchy == null)
+ {
+ return EMPTY_HIERARCHY;
+ }
+ return hierarchy;
+ }
+
private RequestType getManagementRequestType(final String method,
final String categoryName,
final List<String> parts,
@@ -829,7 +841,7 @@ public class LatestManagementController extends AbstractManagementController
final Class<? extends ConfiguredObject> configuredClass = getRequestCategoryClass(category, root.getModel());
final ConfiguredObject<?> target;
final ConfiguredObjectFinder finder = getConfiguredObjectFinder(root);
- final Class<? extends ConfiguredObject>[] hierarchy = finder.getHierarchy(configuredClass);
+ final Class<? extends ConfiguredObject>[] hierarchy = getHierarchy(finder, configuredClass);
if (names.isEmpty() && hierarchy.length == 0)
{
target = root;
diff --git a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/OperationTest.java b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/OperationTest.java
index ade744a..6a06855 100644
--- a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/OperationTest.java
+++ b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/OperationTest.java
@@ -106,4 +106,25 @@ public class OperationTest extends HttpTestBase
SC_OK);
assertThat(response, is(nullValue()));
}
+
+ @Test
+ public void invokeOperationForUnknownCategory() throws Exception
+ {
+
+ try
+ {
+ getHelper().postJson("broker/performGC",
+ Collections.emptyMap(),
+ new TypeReference<Void>()
+ {
+ },
+ SC_NOT_FOUND);
+ fail("The request is executed against root object VirtualHost. Thus, any broker request should fail.");
+ }
+ catch (FileNotFoundException e)
+ {
+ //pass
+ }
+
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org