Skip to content

Commit

Permalink
Merge pull request #16 from mtakaki/mtakaki_upgrade_dw_fix_NPE
Browse files Browse the repository at this point in the history
Upgrading to dropwizard 1.1.0 and fixing NPE thrown when there's a 404
  • Loading branch information
mtakaki committed Apr 22, 2017
2 parents ce02387 + 0e71676 commit f9a9b54
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -25,6 +25,7 @@ These are the supported versions of dropwizard:
| 0.9.X | 0.0.6 |
| 1.0.0 | 1.0.0 |
| 1.0.5 | 1.0.5 |
| 1.1.0 | 1.1.0 |

## Stand-alone

Expand Down
18 changes: 9 additions & 9 deletions pom.xml
Expand Up @@ -3,7 +3,7 @@

<groupId>com.github.mtakaki</groupId>
<artifactId>dropwizard-circuitbreaker</artifactId>
<version>1.0.6-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>dropwizard-circuitbreaker</name>
Expand All @@ -29,7 +29,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dropwizard.version>1.0.5</dropwizard.version>
<dropwizard.version>1.1.0</dropwizard.version>
<!-- Flaky test setting, re-run more 2 times in case of a failure -->
<surefire.rerunFailingTestsCount>2</surefire.rerunFailingTestsCount>
</properties>
Expand Down Expand Up @@ -57,7 +57,7 @@
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>${dropwizard.version}</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>

<dependency>
Expand All @@ -78,21 +78,21 @@
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.1.2</version>
<version>3.2.2</version>
</dependency>

<!-- Avoids boilerplate code -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
<version>1.16.12</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
<version>3.5</version>
</dependency>

<!-- jUnit for unit testing -->
Expand All @@ -113,7 +113,7 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.5.2</version>
<version>3.6.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -124,7 +124,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down Expand Up @@ -160,7 +160,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
<version>0.7.8</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand Down
Expand Up @@ -158,6 +158,11 @@ private void registerCircuitBreakerAnnotations(final List<ResourceMethod> resour
* {@code Optional.empty()} if it's not annotated.
*/
private Optional<String> getCircuitBreakerName(final ResourceMethod resourceMethod) {
// Apparently resourceMethod can be null.
if (resourceMethod == null) {
return Optional.empty();
}

try (Timer.Context context = this.requestOverheadTimer.time()) {
final Invocable invocable = resourceMethod.getInvocable();
Method method = invocable.getDefinitionMethod();
Expand Down
Expand Up @@ -179,6 +179,18 @@ public void testCustomMeterCountIsIncremented() {
assertThat(openCircuitMeter.getCount()).isEqualTo(beforeOpenCircuitCount);
}

@Test
public void testInvalidURI() {
when(circuitBreakerManager.get().isCircuitOpen("custom")).thenReturn(false);

// An invalid URI should return 404 and not fail.
final Response response = client.target(
String.format("http://localhost:%d/wrong", this.RULE.getLocalPort()))
.request().get();

assertThat(response.getStatus()).isEqualTo(404);
}

/**
* Testing that when the circuit is open we should get 503 responses.
*/
Expand Down

0 comments on commit f9a9b54

Please sign in to comment.