diff --git a/build.gradle b/build.gradle index 55ce16e01..d55cb0752 100644 --- a/build.gradle +++ b/build.gradle @@ -34,6 +34,10 @@ apply plugin: 'com.wiredforcode.spawn' sourceCompatibility = 1.8 targetCompatibility = 1.8 +ext { + SpotBugsTask = com.github.spotbugs.SpotBugsTask +} + apply from: file('gradle/dependencies.gradle') apply from: file('gradle/check.gradle') apply from: file('gradle/integration.gradle') @@ -152,4 +156,4 @@ task copyDashboardResources(type: Copy, dependsOn: buildDashboard) { into dashboardResourceFolder } -apply from: file('gradle/develop.gradle') +apply from: file('gradle/develop.gradle') \ No newline at end of file diff --git a/codequality/findbugs_default.xsl b/codequality/findbugs_default.xsl deleted file mode 100644 index 2e254014f..000000000 --- a/codequality/findbugs_default.xsl +++ /dev/null @@ -1,376 +0,0 @@ - - - - - - - - - - -   - - - - - - Code - Warning - - - - - - - FindBugs Report - - - - - - - - - -

FindBugs Report

- -

Project Information

- - -

Metrics

- - -

Contents

- - -

Summary

- - - - - - - - - - - - tablerow0 - tablerow1 - - - - - - - - - - - tablerow0 - tablerow1 - - - - - - -
Warning TypeNumber
Warnings
Total
- -

Warnings

- -

Click on a warning row to see full context information.

- - - - - - - - - Warnings - Warnings_ - - - -

Details

- - - - - - - - -
- - -

Project: - - - - -

-

FindBugs version:

- -

Code analyzed:

-
    - -
  • -
    -
-



-
- - - - - - - - priority- - - - - - - - - - - - - - - - - - - - - -

:

- -
- - - - - - -

- - - - - - -
-
- - - - - -

lines of code analyzed, - in classes, - in packages.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MetricTotalDensity*
High Priority Warnings - - - - - - - - -
Medium Priority Warnings - - - - - - - - -
Low Priority Warnings - - - - - - - - -
Total Warnings
-

(* Defects per Thousand lines of non-commenting source statements)

-



- -
- -
- - diff --git a/gradle/buildscript.gradle b/gradle/buildscript.gradle index e43095d74..715e93812 100644 --- a/gradle/buildscript.gradle +++ b/gradle/buildscript.gradle @@ -16,16 +16,20 @@ repositories { jcenter() + maven { url 'https://plugins.gradle.org/m2/' } maven { url 'http://dl.bintray.com/vermeulen-mp/gradle-plugins' } } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3' - classpath "net.saliman:gradle-cobertura-plugin:2.3.2" - classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3' - classpath 'com.github.ksoichiro:gradle-console-reporter:0.4.0' + classpath 'com.github.jengelman.gradle.plugins:shadow:5.0.0' + classpath "net.saliman:gradle-cobertura-plugin:2.6.1" + classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2' + classpath 'com.github.ksoichiro:gradle-console-reporter:0.6.2' classpath group: 'com.typesafe', name: 'config', version: '1.3.1' classpath group: 'org.codehaus.groovy.modules.http-builder', name: 'http-builder', version: '0.7.1' - classpath 'com.github.michaelruocco:embedded-mysql-plugin:2.1.4' + classpath 'com.github.michaelruocco:embedded-mysql-plugin:2.1.10' classpath 'com.wiredforcode:gradle-spawn-plugin:0.8.1' -} \ No newline at end of file + classpath 'org.owasp:dependency-check-gradle:4.0.1' + classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:2.0.0" + classpath 'com.google.guava:guava:27.1-jre' +} diff --git a/gradle/check.gradle b/gradle/check.gradle index a5268e3e2..c67247675 100644 --- a/gradle/check.gradle +++ b/gradle/check.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Nike, Inc. + * Copyright (c) 2019 Nike, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,24 +14,20 @@ * limitations under the License. */ -apply plugin: 'findbugs' +apply plugin: "com.github.spotbugs" apply plugin: 'pmd' apply plugin: "jacoco" apply plugin: 'com.github.kt3k.coveralls' +apply plugin: 'org.owasp.dependencycheck' -findbugs { - ignoreFailures = false - sourceSets = [ project.sourceSets.main ] +spotbugs { + toolVersion = '3.1.12' + sourceSets = [sourceSets.main] } pmd { sourceSets = [ project.sourceSets.main ] -} - -tasks.withType(FindBugs) { - reports { - xml.withMessages = true - } + toolVersion = "5.6.1" } jacoco { @@ -46,17 +42,15 @@ jacocoTestReport { } } +// To generate an HTML report instead of XML +tasks.withType(SpotBugsTask) { + reports.xml.enabled = false + reports.html.enabled = true +} + test.finalizedBy(project.tasks.jacocoTestReport) -task findbugsHtml { - group = "Verification" - description = "Creates a human readable Findbugs report" - doLast { - ant.xslt(in: file("$buildDir/reports/findbugs/main.xml"), - style: file('codequality/findbugs_default.xsl'), - out: new File("$buildDir/reports/findbugs/main.html")) - } -} -findbugsMain.finalizedBy findbugsHtml +tasks.check.dependsOn 'dependencyCheckAnalyze' +tasks.check.dependsOn 'spotbugsMain' tasks.coveralls.dependsOn check diff --git a/gradle/integration.gradle b/gradle/integration.gradle index eaec00a23..44b519825 100644 --- a/gradle/integration.gradle +++ b/gradle/integration.gradle @@ -31,7 +31,7 @@ configurations { } task integrationTest(type: Test) { - testClassesDir = sourceSets.integrationTest.output.classesDir + testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath } @@ -41,7 +41,6 @@ integrationTest { } } - dependencies { integrationTestCompile sourceSets.main.output integrationTestCompile configurations.testCompile diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d5c591c9c..3baa851b2 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1916c7982..4f7bd6547 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,22 +1,6 @@ -# -# Copyright (c) 2016 Nike, Inc. -# -# Licensed 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. -# - -#Tue Jul 01 11:06:28 PDT 2014 +#Mon Jun 03 15:19:19 PDT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/gradlew b/gradlew index 91a7e269e..27309d923 100755 --- a/gradlew +++ b/gradlew @@ -6,12 +6,30 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,31 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -90,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -114,6 +113,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` diff --git a/gradlew.bat b/gradlew.bat index aec99730b..f6d5974e7 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,7 +46,7 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windowz variants +@rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args if "%@eval[2+2]" == "4" goto 4NT_args diff --git a/src/main/java/com/nike/cerberus/service/DistributedLockService.java b/src/main/java/com/nike/cerberus/service/DistributedLockService.java index e32d8bbdf..ca1a6a26f 100644 --- a/src/main/java/com/nike/cerberus/service/DistributedLockService.java +++ b/src/main/java/com/nike/cerberus/service/DistributedLockService.java @@ -136,10 +136,13 @@ public void executeServerShutdownHook(ServerConfig serverConfig, Channel channel locks.forEach((name, lock) -> { try { lock.release(); - lock.semaphore.tryAcquire(3, TimeUnit.SECONDS); + boolean didAcquireLock = lock.semaphore.tryAcquire(3, TimeUnit.SECONDS); + if (!didAcquireLock) { + throw new RuntimeException("Failed to acquire semaphore"); + } locks.remove(name); - } catch (InterruptedException e) { - log.error("Failed to gracefully release lock: {}, interrupting thread", e); + } catch (Exception e) { + log.error("Failed to gracefully release lock: {}, interrupting thread", name, e); lock.interrupt(); } });