Skip to content

Commit

Permalink
2.0.0 (#56)
Browse files Browse the repository at this point in the history
* Refactored from gradle to maven
* Upgraded dependencies
* Removed response body from read API error message
* Allow for unit tests to run without API key
* API usability improvements
* Now parses messages out of ContextedExceptions
* Sort system properties
* API for reporting custom built requests improved
* Fixed assorted errors and error-prone issues

* Enable checkstyle, with a few caveats: JavaDoc isn't yet required, but will probably turn that on sometime during 2.x lifecycle; a couple of defaults were globally disabled because our project diverges too much from those rules.
* We may want to turn on checkstyle in the build/compile phase. But right now it's only in the site phase and won't cause builds to fail.
* The serialization code initially relies on some naming conventions divergent
from Java conventions, so some style checks are suppressed (see
./suppresions.xml) (this might be an obsolete comment)
* A few Sun conventions are disabled in ./checkstyle.xml because they
are either problematic in a library context or they just don't make a
lot of sense for this project.
* Applying various checkstyle recommendations across the project
* Add final to method parameters that aren't modified
* Convert most protected fields to protected accessors
  I don't have any religion on this, but it's consistent with Sun style,
  and there's no clear reason to fight it.
* Punting on Visibility/Naming for the DefaultsConfigContext (checkstyle)
* Revised tests to support GSON->Jackson refactoring
* Tweak field naming to match Sun conventions
* Update checkstyle dependency version
* Remove remaining DTO suppressions, switch to accessors
* Migrate to JSON serialization to Jackson
  - Sticks with 2.8.11 (provided version) to avoid convergent dependency
issues
  - Will need to deal with Map serialization mechanism change in Jackson
2.9
* Avoid Thread Local Storage in deserialization of Notices

Issue #48 on the honeybadger-io github issues list

- candidate solution for removing thread local hack in
HoneyBadgerNoticeLoader
- Uses a Jackson-specific feature for injecting values.
- passes integration tests locally, but may need to do some additional
work to be sure it works all the way down the object graph
- Probably need to remove a deprecated constructor or two in the DTOs

* Fix multiple serialization and deserialization issues
* This exposed a bit of a flaw in the HoneyBadgerNoticeLoader design,
but because the only known use of that code is in Integration tests,
I've implemented a change in the test. Load data and Memory usage is not
available from the Notice retrieval API, and it was previously
automatically generated at construction time, or via the thread-local
version of configContext.

* Revise Readme instructions for testing
* Update test instructions

-  Still not quite sure how to do maven release yet since I don't have
experience publishing to public maven repos, but I can probably update
the instructions when we're a little closer

* Modify readme to explain tag feature
* Implement most of Elijah's suggestions

* Implement other minor code review suggestions

* Support configurable retry attempts (#57)

Issue #47

- Discovered and fixed an unexpected bug that skipped retries in the case of an IO Exception
- Added system property maximum_retry_attempts
(Integer, constraints: value >= 1)
- Changed the logic so the property is actually the max number of
retries, not attempts. (This is a difference in behavior from 1.0)
- Added explanatory note to property usage in Readme
- Appropriate tests for retry logic
- Fix a few more minor checkstyle complaints introduced with configurable retry logic feature
  • Loading branch information
JasonTrue committed Aug 9, 2018
1 parent cf3203e commit 6e0df0a
Show file tree
Hide file tree
Showing 100 changed files with 3,662 additions and 2,264 deletions.
102 changes: 74 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,40 +1,72 @@
# Created by http:https://www.gitignore.io

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm

## Directory-based project format
.idea/

# if you remove the above rule, at least ignore user-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# and these sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# and, if using gradle::
# .idea/gradle.xml
# .idea/libraries

## File-based project format
*.ipr
## Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

.idea/*

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws
*.iml

## Additional for IntelliJ
out/
## Plugin-specific files:

# generated by mpeltonen/sbt-idea plugin
# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# generated by JIRA plugin
# JIRA plugin
atlassian-ide-plugin.xml

# generated by Crashlytics plugin (for Android Studio and Intellij)
# Cursive Clojure plugin
.idea/replstate.xml

# Ruby plugin and RubyMine
/.rakeTasks

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

*.iml
modules.xml
# .idea/misc.xml
*.ipr

# Sonarlint plugin
.idea/sonarlint


### Java ###
*.class
Expand Down Expand Up @@ -62,4 +94,18 @@ gradle-app.setting
gradle.properties

# Allow gradle wrapper binary
!gradle/wrapper/gradle-wrapper.jar
!gradle/wrapper/gradle-wrapper.jar

### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties

# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
79 changes: 75 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,76 @@
dist: trusty
language: java
jdk:
- oraclejdk7
- openjdk7
- oraclejdk8
# We now cache the Maven dependencies directory for faster builds
cache:
apt: true
directories:
- $HOME/.m2
- $HOME/.downloads
sudo: true

addons:
apt:
sources:
- sourceline: 'deb http:https://repos.azulsystems.com/ubuntu stable main'
key_url: 'http:https://repos.azulsystems.com/RPM-GPG-KEY-azulsystems'
packages:
- zulu-8
- zulu-9

# Oracle JDK 8 and the OpenJDK 8 are both installed by default by TravisCI
# Additionally, they both have the unlimited JCE policy installed as well.
# This is why we do not explicitly installed them in our Travis CI
# configuration.

before_install:
- echo 'MAVEN_OPTS="-Dorg.slf4j.simpleLogger.defaultLogLevel=warn"' >~/.mavenrc
- mkdir -p $HOME/.downloads
- wget -N -q -O $HOME/.downloads/ZuluJCEPolicies.zip 'https://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip'
# The SHA256 checksum for JCE for Azul will break if Azul updates their archive.
# If so, you will need to update the fingerprint below after verifying the
# authenticity of the archive.
- echo "8021a28b8cac41b44f1421fd210a0a0822fcaf88d62d2e70a35b2ff628a8675a $HOME/.downloads/ZuluJCEPolicies.zip" | sha256sum -c
- sudo unzip -o -j $HOME/.downloads/ZuluJCEPolicies.zip ZuluJCEPolicies/local_policy.jar ZuluJCEPolicies/US_export_policy.jar -d /usr/lib/jvm/zulu-8-amd64/jre/lib/security
- sudo unzip -o -j $HOME/.downloads/ZuluJCEPolicies.zip ZuluJCEPolicies/local_policy.jar ZuluJCEPolicies/US_export_policy.jar -d /usr/lib/jvm/zulu-9-amd64/lib/security


matrix:
fast_finish: true
include:
# checkstyle
# - jdk: oraclejdk8
# env:
# - DESC="checkstyle"
# - CMD="mvn clean checkstyle:check"
# - LANG=en_US.utf8
# unit tests (oraclejdk8)
- jdk: oraclejdk8
env:
- DESC="oraclejdk8 unit tests"
- CMD="mvn clean test -Dcheckstyle.skip=true"
- LANG=en_US.utf8
# unit tests (openjdk8)
- jdk: openjdk8
env:
- DESC="openjdk8 unit tests"
- CMD="mvn clean test -Dcheckstyle.skip=true"
- LANG=en_US.utf8
# unit tests (zulu-8)
- env:
- JAVA_HOME=/usr/lib/jvm/zulu-8-amd64
- DESC="zulu-8 unit tests"
- CMD="mvn clean test -Dcheckstyle.skip=true"
- LANG=en_US.utf8
- jdk: oraclejdk9
env:
- DESC="oraclejdk9 unit tests"
- CMD="mvn clean test -Dcheckstyle.skip=true"
- LANG=en_US.utf8
# unit tests (zulu-9)
- env:
- JAVA_HOME=/usr/lib/jvm/zulu-9-amd64
- DESC="zulu-9 unit tests"
- CMD="mvn clean test -Dcheckstyle.skip=true"
- LANG=en_US.utf8

script: echo ${CMD}; ${CMD}
58 changes: 38 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pass around Honeybadger error ids instead of the default Play error ids.
#### Spring Framework Usage

This library has been tested against Spring 4.2.2 using Spring Boot. After adding
Hondeybadger as a dependency to your dependency manager as explained
Honeybadger as a dependency to your dependency manager as explained
in the [Install the jar section](#instal-the-jar-section), you can enable Honeybadger
as an error handler by adding the `honeybadger.api_key` configuration parameter to
your [Spring configuration](http:https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html).
Expand Down Expand Up @@ -238,6 +238,7 @@ Framework specific configuration contexts use of environment variables or system
| **Name**: `honeybadger.excluded_exception_classes`<br>**Type**: CSV<br>**Required**: No<br>**Default**: N/A<br>**Sample Value**: `co.foo.Exception`,<br>`com.myorg.AnnoyingException` | CSV of Java classes in which errors are never sent to Honeybadger. This is useful for errors that are bubbled up from underlying frameworks or application servers like Tomcat. If you are using Tomcat, you may want to include `org.apache.catalina.connector.ClientAbortException`. |
| **Name**: `honeybadger.excluded_sys_props`<br>**Type**: CSV<br>**Required**: No<br>**Default**: `honeybadger.api_key`,<br>`honeybadger.read_api_key`,<br>`honeybadger.excluded_sys_props`,<br>`honeybadger.url`<br>**Sample Value**: `bonecp.password`,`bonecp.username` | CSV of Java system properties to exclude from being logged to Honeybadger. This is useful for excluding authentication information. Default values are automatically added. |
| **Name**: `honeybadger.excluded_params`<br>**Type**: CSV<br>**Required**: No<br>**Default**: N/A<br>**Sample Value**: `auth_token`,<br>`session_data`,<br>`credit_card_number` | CSV of HTTP GET/POST query parameter values that will be excluded from the data sent to Honeybadger. This is useful for excluding authentication information, parameters that are too long or sensitive. |
| **Name**: `honeybadger.maximum_retry_attempts`<br>**Type**: Integer<br>**Required: No<br>**Default**: 3<br>**Sample Value:** 3 (must be >= 0) | Number of times HoneybadgerReporter will retry delivering an error report if the first attempt fails. (If set to 3, retries up to 3 times before giving up; if set to 0, tries once and gives up).
| &nbsp;||||
| __FEEDBACK_FORM__||||
| **Name**: `honeybadger.display_feedback_form`<br>**Type**: Boolean<br>**Required**: No<br>**Default**: `true`<br>**Sample Value**: `false` | Displays the feedback form or JSON output when an error is thrown via a servlet call. |
Expand Down Expand Up @@ -286,6 +287,19 @@ on the fault detail page.
This behavior is enabled by default. To disable it set the configuration option
`honeybadger.display_feedback_form` to `false`.

### Using tags

This version of honeybadger-java supports sending tags, but it requires
invoking a new overload of

```
NoticeReporter.reportError(Throwable error, Object request, String message, Iterable<String> tags);
```

The existing error handler/filter implementations for Play, Spring, and Servlets do not
currently invoke this variant. Those implementations can be overridden
to customize the tagging behavior for your application.

## Changelog

See https://github.com/honeybadger-io/honeybadger-java/blob/master/changes.txt
Expand All @@ -300,47 +314,51 @@ as a preliminary step; that way you can be (moderately) sure that your pull requ
1. Fork it.
2. Create a topic branch `git checkout -b my_branch`
3. Configure integration tests to use your API keys (see below).
4. Run unit and integration tests `./gradlew check`
4. Run unit and integration tests `./mvn verify`
5. Commit your changes `git commit -am "Boom"`
6. Push to your branch `git push origin my_branch`
7. Send a [pull request](https://github.com/honeybadger-java/honeybadger-java/pulls)

### Testing
For the purpose of one off testing, you can use the CLI utility. Just execute it using
```./gradlew run``` and you can enter in your API key and message to be sent to
Honeybadger.
```mvn exec:java -Dexec.mainClass="io.honeybadger.reporter.HoneybadgerCLI"``` from the `honeybadger-java`
subdirectory and you can enter in your API key and message to be sent to Honeybadger.

#### Running the tests

This library by requires access to the remote Honeybadger API, so in order to
run automated tests you will need to specify system properties to Java in order
configure the remote API key and other settings.

If you are running the tests from gradle, it is easy to specify system properties
using a gradle.properties file placed in the root of the project or in your
$HOME/.gradle directory.
If you are running the tests from maven, the simplest solution is to set
environment variables to do this.

A sample gradle.properties file may look like:
ENV=test
HONEYBADGER_API_KEY=b889a6b2
HONEYBADGER_READ_API_KEY=1b331858d937b5ba8f4c07c1f39c0127903980c8e013367e15a40fcee2fcb74e

```
systemProp.ENV = TEST
systemProp.honeybadger.api_key = 1efa3d71
```

With this in place you can run the tests from gradle by using the wrapped
version of gradle that is bundled with the project by:

```
./gradlew check
mvn verify
```

If you are executing your tests from an IDE like IntelliJ, you may need to
manually set the system variables as part of the test run configuration.

For developers pushing to Maven repositories, you will need to specify
the location of your signing keys in gradle.properties. You also shouldn't
put the file in the project root, but rather store it in your .gradle directory
within your home directory. Properties for signing look like:
the location of your signing keys in ~/.m2/settings.xml.

Properties for signing look like:
```
<settings>
<servers>
<server>
<id>ossrh</id>
<username>your-jira-id</username>
<password>your-jira-pwd</password>
</server>
</servers>
</settings>
```

```
signing.keyId=345A20CE
Expand Down
Loading

0 comments on commit 6e0df0a

Please sign in to comment.