Chia-Ping Tsai created KAFKA-21655:
--------------------------------------

             Summary: Drop the version 0 check in the ACLs path
                 Key: KAFKA-21655
                 URL: https://issues.apache.org/jira/browse/KAFKA-21655
             Project: Kafka
          Issue Type: Improvement
            Reporter: Chia-Ping Tsai
            Assignee: Chia-Ping Tsai


Version 0 of the ACL RPCs was removed in 4.0, so the following dead code should 
be dropped.
{code:java}
        if (version == 0) {
            final boolean unsupported = filterResults().stream()
                .flatMap(r -> r.matchingAcls().stream())
                .anyMatch(matchingAcl -> matchingAcl.patternType() != 
PatternType.LITERAL.code());
            if (unsupported)
                throw new UnsupportedVersionException("Version 0 only supports 
literal resource pattern types");
        }
{code}
{code:java}
 
        if (version() == 0) {             for 
(DeleteAclsRequestData.DeleteAclsFilter filter : data.filters()) {              
   PatternType patternType = PatternType.fromCode(filter.patternTypeFilter());  
              // On older brokers, no pattern types existed except LITERAL 
(effectively). So even though ANY is not                 // directly supported 
on those brokers, we can get the same effect as ANY by setting the pattern type 
                // to LITERAL. Note that the wildcard `*` is considered 
`LITERAL` for compatibility reasons.                 if (patternType == 
PatternType.ANY)                     
filter.setPatternTypeFilter(PatternType.LITERAL.code());                 else 
if (patternType != PatternType.LITERAL) {                     throw new 
UnsupportedProtocolFieldException(patternType.name(), apiKey().name(), 
version(), 1);                 }             }         }
{code}
 
{code:java}
        if (version == 0) {
            PatternType patternType = 
PatternType.fromCode(data.patternTypeFilter());
            // On older brokers, no pattern types existed except LITERAL 
(effectively). So even though ANY is not
            // directly supported on those brokers, we can get the same effect 
as ANY by setting the pattern type
            // to LITERAL. Note that the wildcard `*` is considered `LITERAL` 
for compatibility reasons.
            if (patternType == PatternType.ANY)
                data.setPatternTypeFilter(PatternType.LITERAL.code());
            else if (patternType != PatternType.LITERAL) {
                throw new UnsupportedProtocolFieldException(patternType.name(), 
apiKey().name(), version, 1);
            }
        }


        if (version.isPresent() && version.get() == 0) {
            final boolean unsupported = acls().stream()
                .anyMatch(acl -> acl.patternType() != 
PatternType.LITERAL.code());
            if (unsupported) {
                throw new UnsupportedVersionException("Version 0 only supports 
literal resource pattern types");
            }
        }
{code}
 



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to