madrob commented on code in PR #825:
URL: https://github.com/apache/solr/pull/825#discussion_r862046846
##########
solr/solrj/src/java/org/apache/solr/common/util/Utils.java:
##########
@@ -302,10 +302,16 @@ public static byte[] toUTF8(CharArr out) {
}
public static Object fromJSON(byte[] utf8) {
+ if (utf8 == null || utf8.length == 0) {
+ return Collections.emptyMap();
+ }
return fromJSON(utf8, 0, utf8.length);
}
public static Object fromJSON(byte[] utf8, int offset, int length) {
+ if (utf8 == null || utf8.length == 0) {
Review Comment:
Check length parameter here too?
##########
solr/solrj/src/java/org/apache/solr/common/util/Utils.java:
##########
@@ -302,10 +302,16 @@ public static byte[] toUTF8(CharArr out) {
}
public static Object fromJSON(byte[] utf8) {
+ if (utf8 == null || utf8.length == 0) {
+ return Collections.emptyMap();
+ }
Review Comment:
Add this comment to the code, somebody will be looking at this in five years
and be confused
##########
solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java:
##########
@@ -198,54 +198,84 @@ public void testCreate() throws Exception {
@Test
public void testCreateWithTrust() throws Exception {
String configsetName = "regular";
- String configsetSuffix = "testCreateWithTrust";
- String configsetSuffix2 = "testCreateWithTrust2";
- uploadConfigSetWithAssertions(configsetName, configsetSuffix, "solr");
- uploadConfigSetWithAssertions(configsetName, configsetSuffix2, null);
+ String trustedConfigsetSuffix = "testCreateWithTrustTrusted";
+ String untrustedConfigsetSuffix = "testCreateWithTrustUntrusted";
+ uploadConfigSetWithAssertions(configsetName, trustedConfigsetSuffix,
"solr");
+ uploadConfigSetWithAssertions(configsetName, untrustedConfigsetSuffix,
null);
try (SolrZkClient zkClient =
new SolrZkClient(
cluster.getZkServer().getZkAddress(), AbstractZkTestCase.TIMEOUT,
45000, null)) {
- assertTrue(isTrusted(zkClient, configsetName, configsetSuffix));
- assertFalse(isTrusted(zkClient, configsetName, configsetSuffix2));
+ assertTrue(isTrusted(zkClient, configsetName, trustedConfigsetSuffix));
+ assertFalse(isTrusted(zkClient, configsetName,
untrustedConfigsetSuffix));
+ // base trusted -> untrusted
+ try {
+ ignoreException("unauthenticated request");
+ // trusted -> untrusted
+ createConfigSet(
+ null, // base is default trusted
+ "abc",
+ Collections.emptyMap(),
+ cluster.getSolrClient(),
+ null); // without username is untrusted
+ fail("Expecting exception");
+ } catch (SolrException e) {
+ assertEquals(SolrException.ErrorCode.UNAUTHORIZED.code, e.code());
Review Comment:
Do we expect an exception always? Should use assertThrows if so.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]