diff --git a/.netflixoss b/.netflixoss new file mode 100644 index 00000000..c31bc6ab --- /dev/null +++ b/.netflixoss @@ -0,0 +1,2 @@ +pullrequest_cloudbees=false +jdk=1.8 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..0d9d095b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: java +jdk: +- oraclejdk8 +sudo: false +install: "./installViaTravis.sh" +script: "./buildViaTravis.sh" +env: + global: + - secure: FeZz9XcTKHnnammp+UHZvDZ2ozrZ9umHi5VRgFD68jOcQ+cxsVIJEIsKWeXbzyLVGpcUPQWGQ2ALtexygfiwS3us2ALzZPOzUJjnh3lvACOavb9DLiF1w82cOz1W+9QWRJv99/vkkp+BfvY/3/QSGTTojL/t+gltzkOf4Ev2cYQ= + - secure: qOHa6Uc5caMVcy31ALhc36Gc/fDQ9T8M9BoXDwvSoYJOOSYVUZBTHzvdC4xV1Tm3XFLa2H8PGCXyDxBkebv6iPyuyUP7eieGkUGC6gbJ2bR9i12WUbXPv/g8Ha0Bb3AC9sUvZ9lc+7MWFmcqbH2iXAbWz+6cGabLioEmFit4vZQ= + - secure: WlWpMitytvmwFa5TAQMPZprm/PGjReZXglgHQ85C/BQTHhyHVK28EwGwBscyRWpY7Dz1yLtCIehLGiiAmmaRa0g/vewRElHoE5gYCZsidlWMk8Q+TosGRGyzXlpNNpi/ME24EtnRsFmfexEF2DelVj2a7o8bS8baYqqU/HDIOw0= + - secure: XlwSpJ8dtqWc4Gq4IzjSHZ6rODa983VQTR5KjcHOCH5pKq2yP3iCkL1EBELSH97JkdSwsa1yHDTvrgPgVfmQGyAdti6pvnb5jOOWL3xCvoy0nwUZSJwbSlyw4IGE2i2X5L7c9yqSgn+KmvoZjrY9NyrXTNdI1LZKtjOdVmN/FxA= +cache: + directories: + - $HOME/.gradle diff --git a/buildViaTravis.sh b/buildViaTravis.sh new file mode 100755 index 00000000..17a33a5f --- /dev/null +++ b/buildViaTravis.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# This script will build the project. + +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + echo -e "Build Pull Request #$TRAVIS_PULL_REQUEST => Branch [$TRAVIS_BRANCH]" + ./gradlew build +elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" == "" ]; then + echo -e 'Build Branch with Snapshot => Branch ['$TRAVIS_BRANCH']' + ./gradlew -Prelease.travisci=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" build snapshot +elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" != "" ]; then + echo -e 'Build Branch for Release => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG']' + case "$TRAVIS_TAG" in + *-rc\.*) + ./gradlew -Prelease.travisci=true -Prelease.useLastTag=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" candidate + ;; + *) + ./gradlew -Prelease.travisci=true -Prelease.useLastTag=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" final + ;; + esac +else + echo -e 'WARN: Should not be here => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG'] Pull Request ['$TRAVIS_PULL_REQUEST']' + ./gradlew build +fi diff --git a/installViaTravis.sh b/installViaTravis.sh new file mode 100755 index 00000000..68e45a05 --- /dev/null +++ b/installViaTravis.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# This script will build the project. + +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + echo -e "Assemble Pull Request #$TRAVIS_PULL_REQUEST => Branch [$TRAVIS_BRANCH]" + ./gradlew assemble +elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" == "" ]; then + echo -e 'Assemble Branch with Snapshot => Branch ['$TRAVIS_BRANCH']' + ./gradlew -Prelease.travisci=true assemble +elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" != "" ]; then + echo -e 'Assemble Branch for Release => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG']' + ./gradlew -Prelease.travisci=true -Prelease.useLastTag=true assemble +else + echo -e 'WARN: Should not be here => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG'] Pull Request ['$TRAVIS_PULL_REQUEST']' + ./gradlew assemble +fi diff --git a/servo-core/src/main/java/com/netflix/servo/jmx/JmxMonitorRegistry.java b/servo-core/src/main/java/com/netflix/servo/jmx/JmxMonitorRegistry.java index 8d6676e2..fefe1b08 100644 --- a/servo-core/src/main/java/com/netflix/servo/jmx/JmxMonitorRegistry.java +++ b/servo-core/src/main/java/com/netflix/servo/jmx/JmxMonitorRegistry.java @@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory; import javax.management.DynamicMBean; +import javax.management.InstanceNotFoundException; import javax.management.MBeanServer; import javax.management.ObjectName; import java.lang.management.ManagementFactory; @@ -122,7 +123,12 @@ public void unregister(Monitor monitor) { try { List beans = MonitorMBean.createMBeans(name, monitor, mapper); for (MonitorMBean bean : beans) { - mBeanServer.unregisterMBean(bean.getObjectName()); + try { + mBeanServer.unregisterMBean(bean.getObjectName()); + } catch (InstanceNotFoundException ignored) { + // ignore errors attempting to unregister a non-registered monitor + // a common error is to unregister twice + } } monitors.remove(monitor.getConfig()); updatePending.set(true);