fapifta commented on code in PR #11813:
URL: https://github.com/apache/ozone/pull/11813#discussion_r4615407485
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/file/OMDirectoryCreateRequest.java:
##########
@@ -97,10 +99,18 @@ public OMRequest preExecute(OzoneManager ozoneManager)
throws IOException {
KeyArgs keyArgs = createDirectoryRequest.getKeyArgs();
- OmUtils.verifyKeyNameWithSnapshotReservedWord(keyArgs.getKeyName());
+ String keyName = keyArgs.getKeyName();
+ if
(getBucketLayout().shouldNormalizePaths(ozoneManager.getEnableFileSystemPaths()))
{
+ // Directory names allow characters such as ':' (HDDS-12911), but must
not retain dot components.
Review Comment:
The comment points to HDDS-12911. That change added
`OMClientRequest.normalizeKeyPath()` for exactly this case: normalize according
to the bucket layout without validating the name.
Could this use the existing helper instead? Something like:
```java
final boolean enableFileSystemPaths =
ozoneManager.getEnableFileSystemPaths();
String keyName = normalizeKeyPath(enableFileSystemPaths,
keyArgs.getKeyName(), getBucketLayout());
// Directory names may contain ':', so the name is not validated, but it
must not keep a ".." component.
if (getBucketLayout().shouldNormalizePaths(enableFileSystemPaths)
&& Arrays.asList(keyName.split(OM_KEY_PREFIX)).contains("..")) {
throw new OMException("Invalid KeyPath " + keyName,
OMException.ResultCodes.INVALID_KEY_NAME);
}
```
This is potentially not a really important one, but it does not call the
getter twice, and calls a more generic method so if someone moves things around
later on it doesn't matter if the shouldnormalize check is around the
normalization method call. I can live with the original version in the PR.
--
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]