Skip to content

Commit

Permalink
MINOR: Update build and test dependencies (apache#9645)
Browse files Browse the repository at this point in the history
The spotbugs upgrade means we can re-enable
RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE and RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE.
These uncovered one bug, one unnecessary null check and one
false positive. Addressed them all, including a test for the bug.

* gradle (6.7.0 -> 6.7.1): minor fixes.
* gradle versions plugin (0.29.0 -> 0.36.0): minor fixes.
* grgit (4.0.2 -> 4.1.0): a few small fixes and dependency bumps.
* owasp dependency checker plugin (5.3.2.1 -> 6.0.3): improved db
schema, data and several fixes. 
* scoverage plugin (4.0.2 -> 5.0.0): support Scala 2.13.
* shadow plugin (6.0.0 -> 6.1.0): require Java 8, support for Java 16.
* spotbugs plugin (4.4.4 -> 4.6.0): support SARIF reporting standard.
* spotbugs (4.0.6 -> 4.1.4): support for Java 16 and various fixes including
try with resources false positive.
* spotless plugin (5.1.0 -> 5.8.2): minor fixes.
* test retry plugin (1.1.6 -> 1.1.9): newer gradle and java version compatibility
fixes.
* mockito (3.5.7 -> 3.6.0): minor fixes.
* powermock (2.0.7 -> 2.0.9): minor fixes.

Release notes links:
* https://docs.gradle.org/6.7.1/release-notes.html
* https://github.com/spotbugs/spotbugs/blob/4.1.4/CHANGELOG.md
* https://github.com/scoverage/gradle-scoverage/releases/tag/5.0.0
* https://github.com/johnrengelman/shadow/releases/tag/6.1.0
* https://github.com/spotbugs/spotbugs-gradle-plugin/releases/tag/4.6.0
* https://github.com/spotbugs/spotbugs-gradle-plugin/releases/tag/4.6.0
* https://github.com/spotbugs/spotbugs-gradle-plugin/releases/tag/4.5.0
* https://github.com/ben-manes/gradle-versions-plugin/releases
* https://github.com/ajoberstar/grgit/releases/tag/4.1.0
* https://github.com/jeremylong/DependencyCheck/blob/main/RELEASE_NOTES.md#version-603-2020-11-03
* https://github.com/powermock/powermock/releases/tag/powermock-2.0.8
* https://github.com/powermock/powermock/releases/tag/powermock-2.0.9
* https://github.com/mockito/mockito/blob/v3.6.0/doc/release-notes/official.md
* https://github.com/gradle/test-retry-gradle-plugin/releases
* https://github.com/diffplug/spotless/blob/main/plugin-gradle/CHANGES.md

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
  • Loading branch information
ijuma authored Nov 24, 2020
1 parent 047ad65 commit a5986bd
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.kafka.clients.admin;

import java.util.Arrays;

/**
* Representation of a SASL/SCRAM Mechanism.
*
Expand All @@ -27,13 +29,15 @@ public enum ScramMechanism {
SCRAM_SHA_256((byte) 1),
SCRAM_SHA_512((byte) 2);

private static final ScramMechanism[] VALUES = values();

/**
*
* @param type the type indicator
* @return the instance corresponding to the given type indicator, otherwise {@link #UNKNOWN}
*/
public static ScramMechanism fromType(byte type) {
for (ScramMechanism scramMechanism : ScramMechanism.values()) {
for (ScramMechanism scramMechanism : VALUES) {
if (scramMechanism.type == type) {
return scramMechanism;
}
Expand All @@ -49,8 +53,10 @@ public static ScramMechanism fromType(byte type) {
* Salted Challenge Response Authentication Mechanism (SCRAM) SASL and GSS-API Mechanisms, Section 4</a>
*/
public static ScramMechanism fromMechanismName(String mechanismName) {
ScramMechanism retvalFoundMechanism = ScramMechanism.valueOf(mechanismName.replace('-', '_'));
return retvalFoundMechanism != null ? retvalFoundMechanism : UNKNOWN;
return Arrays.stream(VALUES)
.filter(mechanism -> mechanism.mechanismName.equals(mechanismName))
.findFirst()
.orElse(UNKNOWN);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
int result = key() != null ? key().hashCode() : 0;
int result = key().hashCode();
result = 31 * result + Arrays.hashCode(value());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.kafka.clients.admin;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

class ScramMechanismTest {

@Test
public void testFromMechanismName() {
assertEquals(ScramMechanism.UNKNOWN, ScramMechanism.fromMechanismName("UNKNOWN"));
assertEquals(ScramMechanism.SCRAM_SHA_256, ScramMechanism.fromMechanismName("SCRAM-SHA-256"));
assertEquals(ScramMechanism.SCRAM_SHA_512, ScramMechanism.fromMechanismName("SCRAM-SHA-512"));
assertEquals(ScramMechanism.UNKNOWN, ScramMechanism.fromMechanismName("some string"));
assertEquals(ScramMechanism.UNKNOWN, ScramMechanism.fromMechanismName("scram-sha-256"));
}

}
24 changes: 12 additions & 12 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ versions += [
bcpkix: "1.66",
checkstyle: "8.20",
commonsCli: "1.4",
gradle: "6.7",
gradleVersionsPlugin: "0.29.0",
grgit: "4.0.2",
gradle: "6.7.1",
gradleVersionsPlugin: "0.36.0",
grgit: "4.1.0",
httpclient: "4.5.12",
easymock: "4.2",
jackson: "2.10.5",
Expand Down Expand Up @@ -95,25 +95,25 @@ versions += [
lz4: "1.7.1",
mavenArtifact: "3.6.3",
metrics: "2.2.0",
mockito: "3.5.7",
mockito: "3.6.0",
netty: "4.1.51.Final",
owaspDepCheckPlugin: "5.3.2.1",
powermock: "2.0.7",
owaspDepCheckPlugin: "6.0.3",
powermock: "2.0.9",
reflections: "0.9.12",
rocksDB: "5.18.4",
scalaCollectionCompat: "2.2.0",
scalafmt: "1.5.1",
scalaJava8Compat : "0.9.1",
scalatest: "3.0.8",
scoverage: "1.4.1",
scoveragePlugin: "4.0.2",
shadowPlugin: "6.0.0",
scoveragePlugin: "5.0.0",
shadowPlugin: "6.1.0",
slf4j: "1.7.30",
snappy: "1.1.8.1",
spotbugs: "4.0.6",
spotbugsPlugin: "4.4.4",
spotlessPlugin: "5.1.0",
testRetryPlugin: "1.1.6",
spotbugs: "4.1.4",
spotbugsPlugin: "4.6.0",
spotlessPlugin: "5.8.2",
testRetryPlugin: "1.1.9",
zinc: "1.3.5",
zookeeper: "3.5.8",
zstd: "1.4.5-12"
Expand Down
16 changes: 6 additions & 10 deletions gradle/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
-->
<FindBugsFilter>

<!-- false positive in Java 11, see https://github.com/spotbugs/spotbugs/issues/756 -->
<Match>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
</Match>

<!-- false positive in Java 11, see https://github.com/spotbugs/spotbugs/issues/756 -->
<Match>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
</Match>

<Match>
<!-- Disable warnings about mutable objects and the use of public fields.
EI_EXPOSE_REP: May expose internal representation by returning reference to mutable object
Expand Down Expand Up @@ -103,6 +93,12 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
</Or>
</Match>

<!-- false positive in Java 11, related to https://github.com/spotbugs/spotbugs/issues/756 but more complex -->
<Match>
<Class name="org.apache.kafka.common.record.KafkaLZ4BlockOutputStream"/>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
</Match>

<Match>
<!-- Suppression for the equals() for extension methods. -->
<Class name="kafka.api.package$ElectLeadersRequestOps"/>
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ esac
# Loop in case we encounter an error.
for attempt in 1 2 3; do
if [ ! -e $APP_HOME/gradle/wrapper/gradle-wrapper.jar ]; then
if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v6.7.0/gradle/wrapper/gradle-wrapper.jar"; then
if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v6.7.1/gradle/wrapper/gradle-wrapper.jar"; then
rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
# Pause for a bit before looping in case the server throttled us.
sleep 5
Expand Down

0 comments on commit a5986bd

Please sign in to comment.