|
@@ -1429,6 +1429,7 @@ public class ZooKeeper implements AutoCloseable {
|
|
final String clientPath = path;
|
|
final String clientPath = path;
|
|
PathUtils.validatePath(clientPath, createMode.isSequential());
|
|
PathUtils.validatePath(clientPath, createMode.isSequential());
|
|
EphemeralType.validateTTL(createMode, -1);
|
|
EphemeralType.validateTTL(createMode, -1);
|
|
|
|
+ validateACL(acl);
|
|
|
|
|
|
final String serverPath = prependChroot(clientPath);
|
|
final String serverPath = prependChroot(clientPath);
|
|
|
|
|
|
@@ -1439,9 +1440,6 @@ public class ZooKeeper implements AutoCloseable {
|
|
request.setData(data);
|
|
request.setData(data);
|
|
request.setFlags(createMode.toFlag());
|
|
request.setFlags(createMode.toFlag());
|
|
request.setPath(serverPath);
|
|
request.setPath(serverPath);
|
|
- if (acl != null && acl.size() == 0) {
|
|
|
|
- throw new KeeperException.InvalidACLException();
|
|
|
|
- }
|
|
|
|
request.setAcl(acl);
|
|
request.setAcl(acl);
|
|
ReplyHeader r = cnxn.submitRequest(h, request, response, null);
|
|
ReplyHeader r = cnxn.submitRequest(h, request, response, null);
|
|
if (r.getErr() != 0) {
|
|
if (r.getErr() != 0) {
|
|
@@ -1532,15 +1530,13 @@ public class ZooKeeper implements AutoCloseable {
|
|
final String clientPath = path;
|
|
final String clientPath = path;
|
|
PathUtils.validatePath(clientPath, createMode.isSequential());
|
|
PathUtils.validatePath(clientPath, createMode.isSequential());
|
|
EphemeralType.validateTTL(createMode, ttl);
|
|
EphemeralType.validateTTL(createMode, ttl);
|
|
|
|
+ validateACL(acl);
|
|
|
|
|
|
final String serverPath = prependChroot(clientPath);
|
|
final String serverPath = prependChroot(clientPath);
|
|
|
|
|
|
RequestHeader h = new RequestHeader();
|
|
RequestHeader h = new RequestHeader();
|
|
setCreateHeader(createMode, h);
|
|
setCreateHeader(createMode, h);
|
|
Create2Response response = new Create2Response();
|
|
Create2Response response = new Create2Response();
|
|
- if (acl != null && acl.size() == 0) {
|
|
|
|
- throw new KeeperException.InvalidACLException();
|
|
|
|
- }
|
|
|
|
Record record = makeCreateRecord(createMode, serverPath, data, acl, ttl);
|
|
Record record = makeCreateRecord(createMode, serverPath, data, acl, ttl);
|
|
ReplyHeader r = cnxn.submitRequest(h, record, response, null);
|
|
ReplyHeader r = cnxn.submitRequest(h, record, response, null);
|
|
if (r.getErr() != 0) {
|
|
if (r.getErr() != 0) {
|
|
@@ -2373,6 +2369,7 @@ public class ZooKeeper implements AutoCloseable {
|
|
{
|
|
{
|
|
final String clientPath = path;
|
|
final String clientPath = path;
|
|
PathUtils.validatePath(clientPath);
|
|
PathUtils.validatePath(clientPath);
|
|
|
|
+ validateACL(acl);
|
|
|
|
|
|
final String serverPath = prependChroot(clientPath);
|
|
final String serverPath = prependChroot(clientPath);
|
|
|
|
|
|
@@ -2380,9 +2377,6 @@ public class ZooKeeper implements AutoCloseable {
|
|
h.setType(ZooDefs.OpCode.setACL);
|
|
h.setType(ZooDefs.OpCode.setACL);
|
|
SetACLRequest request = new SetACLRequest();
|
|
SetACLRequest request = new SetACLRequest();
|
|
request.setPath(serverPath);
|
|
request.setPath(serverPath);
|
|
- if (acl != null && acl.size() == 0) {
|
|
|
|
- throw new KeeperException.InvalidACLException(clientPath);
|
|
|
|
- }
|
|
|
|
request.setAcl(acl);
|
|
request.setAcl(acl);
|
|
request.setVersion(aclVersion);
|
|
request.setVersion(aclVersion);
|
|
SetACLResponse response = new SetACLResponse();
|
|
SetACLResponse response = new SetACLResponse();
|
|
@@ -2945,4 +2939,18 @@ public class ZooKeeper implements AutoCloseable {
|
|
throw ioe;
|
|
throw ioe;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Validates the provided ACL list for null, empty or null value in it.
|
|
|
|
+ *
|
|
|
|
+ * @param acl
|
|
|
|
+ * ACL list
|
|
|
|
+ * @throws InvalidACLException
|
|
|
|
+ * if ACL list is not valid
|
|
|
|
+ */
|
|
|
|
+ private void validateACL(List<ACL> acl) throws KeeperException.InvalidACLException {
|
|
|
|
+ if (acl == null || acl.isEmpty() || acl.contains(null)) {
|
|
|
|
+ throw new KeeperException.InvalidACLException();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|