Check for response variable before using in the whoas publish code

The response variable could be null on unsuccessful response from the
HTTP post.

References #21
This commit is contained in:
Mahesh V Kelkar 2015-03-19 17:25:55 -04:00
parent 0b9cba8731
commit f50b83bd04
20 changed files with 70 additions and 30 deletions

View File

@ -528,11 +528,38 @@ SequentialHookRunner that has run loop around queue pop and publishes the hook r
<p>The clients of whoas library can add "whoas" configuration to build queue and runner of their choice. <p>The clients of whoas library can add "whoas" configuration to build queue and runner of their choice.
See the example below</p> See the example below</p>
</div> </div>
<div class="ulist">
<ul>
<li>
<p>queue: configure type and queue specific parameters</p>
<div class="ulist">
<ul>
<li>
<p>type: full classname for the queue class defined in whoas (e.g. com.github.lookout.whoas.InMemoryQueue)</p>
</li>
<li>
<p>key: key of the list data type (currently applies to redis)</p>
</li>
<li>
<p>hostname: hostname of the distributed queue server (currently applies to redis)</p>
</li>
<li>
<p>port: port of the distributed queue server (currently applies to redis)</p>
</li>
</ul>
</div>
</li>
<li>
<p>runnerType: full classname for the runner class defined in whoas</p>
</li>
</ul>
</div>
<div class="listingblock"> <div class="listingblock">
<div class="content"> <div class="content">
<pre>whoas: <pre>whoas:
queue: queue:
type: "com.github.lookout.whoas.RedisQueue" type: "com.github.lookout.whoas.RedisQueue"
key: "queue"
hostname: "localhost" hostname: "localhost"
port: 6379 port: 6379
runnerType: "com.github.lookout.whoas.SequentialHookRunner"</pre> runnerType: "com.github.lookout.whoas.SequentialHookRunner"</pre>
@ -543,7 +570,7 @@ See the example below</p>
</div> </div>
<div id="footer"> <div id="footer">
<div id="footer-text"> <div id="footer-text">
Last updated 2015-03-18 16:27:04 PDT Last updated 2015-03-19 17:23:59 EDT
</div> </div>
</div> </div>
</body> </body>

View File

@ -6,9 +6,9 @@
<html> <html>
<head> <head>
<!-- Generated by groovydoc (2.4.0) on Wed Mar 18 16:27:43 PDT 2015 --> <!-- Generated by groovydoc (2.4.0) on Thu Mar 19 17:25:23 EDT 2015 -->
<title>AbstractHookQueue (whoas 0.1.4 API)</title> <title>AbstractHookQueue (whoas 0.1.4 API)</title>
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../../../groovy.ico" type="image/x-icon" rel="icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="icon">

View File

@ -6,9 +6,9 @@
<html> <html>
<head> <head>
<!-- Generated by groovydoc (2.4.0) on Wed Mar 18 16:27:43 PDT 2015 --> <!-- Generated by groovydoc (2.4.0) on Thu Mar 19 17:25:23 EDT 2015 -->
<title>AbstractHookRunner (whoas 0.1.4 API)</title> <title>AbstractHookRunner (whoas 0.1.4 API)</title>
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../../../groovy.ico" type="image/x-icon" rel="icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="icon">

View File

@ -6,9 +6,9 @@
<html> <html>
<head> <head>
<!-- Generated by groovydoc (2.4.0) on Wed Mar 18 16:27:43 PDT 2015 --> <!-- Generated by groovydoc (2.4.0) on Thu Mar 19 17:25:23 EDT 2015 -->
<title>HookRequest (whoas 0.1.4 API)</title> <title>HookRequest (whoas 0.1.4 API)</title>
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../../../groovy.ico" type="image/x-icon" rel="icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="icon">

View File

@ -6,9 +6,9 @@
<html> <html>
<head> <head>
<!-- Generated by groovydoc (2.4.0) on Wed Mar 18 16:27:43 PDT 2015 --> <!-- Generated by groovydoc (2.4.0) on Thu Mar 19 17:25:23 EDT 2015 -->
<title>InMemoryQueue (whoas 0.1.4 API)</title> <title>InMemoryQueue (whoas 0.1.4 API)</title>
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../../../groovy.ico" type="image/x-icon" rel="icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="icon">

View File

@ -6,9 +6,9 @@
<html> <html>
<head> <head>
<!-- Generated by groovydoc (2.4.0) on Wed Mar 18 16:27:43 PDT 2015 --> <!-- Generated by groovydoc (2.4.0) on Thu Mar 19 17:25:23 EDT 2015 -->
<title>Publisher (whoas 0.1.4 API)</title> <title>Publisher (whoas 0.1.4 API)</title>
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../../../groovy.ico" type="image/x-icon" rel="icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="icon">

View File

@ -6,9 +6,9 @@
<html> <html>
<head> <head>
<!-- Generated by groovydoc (2.4.0) on Wed Mar 18 16:27:43 PDT 2015 --> <!-- Generated by groovydoc (2.4.0) on Thu Mar 19 17:25:23 EDT 2015 -->
<title>RedisQueue (whoas 0.1.4 API)</title> <title>RedisQueue (whoas 0.1.4 API)</title>
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../../../groovy.ico" type="image/x-icon" rel="icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="icon">

View File

@ -6,9 +6,9 @@
<html> <html>
<head> <head>
<!-- Generated by groovydoc (2.4.0) on Wed Mar 18 16:27:43 PDT 2015 --> <!-- Generated by groovydoc (2.4.0) on Thu Mar 19 17:25:23 EDT 2015 -->
<title>SequentialHookRunner (whoas 0.1.4 API)</title> <title>SequentialHookRunner (whoas 0.1.4 API)</title>
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../../../groovy.ico" type="image/x-icon" rel="icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="icon">

View File

@ -6,9 +6,9 @@
<html> <html>
<head> <head>
<!-- Generated by groovydoc (2.4.0) on Wed Mar 18 16:27:43 PDT 2015 --> <!-- Generated by groovydoc (2.4.0) on Thu Mar 19 17:25:23 EDT 2015 -->
<title>WhoasConfiguration (whoas 0.1.4 API)</title> <title>WhoasConfiguration (whoas 0.1.4 API)</title>
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../../../groovy.ico" type="image/x-icon" rel="icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="icon">

View File

@ -6,9 +6,9 @@
<html> <html>
<head> <head>
<!-- Generated by groovydoc (2.4.0) on Wed Mar 18 16:27:43 PDT 2015 --> <!-- Generated by groovydoc (2.4.0) on Thu Mar 19 17:25:23 EDT 2015 -->
<title>WhoasFactory (whoas 0.1.4 API)</title> <title>WhoasFactory (whoas 0.1.4 API)</title>
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../../../groovy.ico" type="image/x-icon" rel="icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="icon">
@ -203,7 +203,7 @@ if (location.href.indexOf('is-external=true') == -1) {
<a name="queueConfig"><!-- --></a> <a name="queueConfig"><!-- --></a>
<ul class="blockListLast"> <ul class="blockListLast">
<li class="blockList"> <li class="blockList">
<h4>@com.fasterxml.jackson.annotation.JsonProperty <h4>@com.fasterxml.jackson.annotation.JsonProperty(value = "queue")
<a href='../../../../com/github/lookout/whoas/WhoasQueueConfig.html'>WhoasQueueConfig</a> <strong>queueConfig</strong></h4> <a href='../../../../com/github/lookout/whoas/WhoasQueueConfig.html'>WhoasQueueConfig</a> <strong>queueConfig</strong></h4>
<p> Queue configuration <p> Queue configuration
</p> </p>
@ -268,7 +268,7 @@ java.lang.String <strong>runnerType</strong></h4>
InstantiationException - if this Class represents an abstract class, an interface, InstantiationException - if this Class represents an abstract class, an interface,
an array class, a primitive type, or void an array class, a primitive type, or void
or if the class has no nullary constructor or if the class has no nullary constructor
or if the instantiation fails for some other reason. <DL><DT><B>Returns:</B></DT><DD></DD></DL><DL><DT><B>Parameters:</B></DT><DD><code>hookQueue</code> - queue to associate with allocated runner</DD></DL></p> or if the instantiation fails for some other reason. <DL><DT><B>Parameters:</B></DT><DD><code>hookQueue</code> - queue to associate with allocated runner</DD></DL><DL><DT><B>Returns:</B></DT><DD></DD></DL></p>
</li> </li>
</ul> </ul>

View File

@ -6,9 +6,9 @@
<html> <html>
<head> <head>
<!-- Generated by groovydoc (2.4.0) on Wed Mar 18 16:27:43 PDT 2015 --> <!-- Generated by groovydoc (2.4.0) on Thu Mar 19 17:25:23 EDT 2015 -->
<title>WhoasQueueConfig (whoas 0.1.4 API)</title> <title>WhoasQueueConfig (whoas 0.1.4 API)</title>
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../../../groovy.ico" type="image/x-icon" rel="icon"> <link href="../../../../groovy.ico" type="image/x-icon" rel="icon">

View File

@ -5,7 +5,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Generated by groovydoc (2.4.0) on --> <!-- Generated by groovydoc (2.4.0) on -->
<title>Deprecated API (whoas 0.1.4 API)</title> <title>Deprecated API (whoas 0.1.4 API)</title>
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<link href="groovy.ico" type="image/x-icon" rel="shortcut icon"> <link href="groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="groovy.ico" type="image/x-icon" rel="icon"> <link href="groovy.ico" type="image/x-icon" rel="icon">

View File

@ -8,7 +8,7 @@
<title>API Help (whoas 0.1.4 API)</title> <title>API Help (whoas 0.1.4 API)</title>
<link href="groovy.ico" type="image/x-icon" rel="shortcut icon"> <link href="groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="groovy.ico" type="image/x-icon" rel="icon"> <link href="groovy.ico" type="image/x-icon" rel="icon">
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head> </head>
<body class="center"> <body class="center">

View File

@ -5,7 +5,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Generated by groovydoc (2.4.0) on --> <!-- Generated by groovydoc (2.4.0) on -->
<title>Index (whoas 0.1.4 API)</title> <title>Index (whoas 0.1.4 API)</title>
<meta name="date" content="2015-03-18"> <meta name="date" content="2015-03-19">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head> </head>
<body class="center"> <body class="center">

View File

@ -566,7 +566,7 @@ the <strong>server-side</strong> component, i.e. a "webhook publisher."</p>
</div> </div>
<div id="footer"> <div id="footer">
<div id="footer-text"> <div id="footer-text">
Last updated 2014-12-31 12:10:04 PST Last updated 2015-03-13 11:50:54 EDT
</div> </div>
</div> </div>
</body> </body>

View File

@ -581,7 +581,7 @@ request</p>
</div> </div>
<div id="footer"> <div id="footer">
<div id="footer-text"> <div id="footer-text">
Last updated 2014-12-30 22:15:54 PST Last updated 2015-03-13 11:50:54 EDT
</div> </div>
</div> </div>
</body> </body>

View File

@ -11,10 +11,18 @@ Library Configuration
The clients of whoas library can add "whoas" configuration to build queue and runner of their choice. The clients of whoas library can add "whoas" configuration to build queue and runner of their choice.
See the example below See the example below
* queue: configure type and queue specific parameters
** type: full classname for the queue class defined in whoas (e.g. com.github.lookout.whoas.InMemoryQueue)
** key: key of the list data type (currently applies to redis)
** hostname: hostname of the distributed queue server (currently applies to redis)
** port: port of the distributed queue server (currently applies to redis)
* runnerType: full classname for the runner class defined in whoas
---- ----
whoas: whoas:
queue: queue:
type: "com.github.lookout.whoas.RedisQueue" type: "com.github.lookout.whoas.RedisQueue"
key: "queue"
hostname: "localhost" hostname: "localhost"
port: 6379 port: 6379
runnerType: "com.github.lookout.whoas.SequentialHookRunner" runnerType: "com.github.lookout.whoas.SequentialHookRunner"

View File

@ -30,7 +30,6 @@ abstract class AbstractHookQueue {
*/ */
abstract Long getSize() abstract Long getSize()
/** /**
* *
*/ */

View File

@ -7,6 +7,7 @@ import javax.ws.rs.client.Invocation
import javax.ws.rs.core.Response import javax.ws.rs.core.Response
import javax.ws.rs.ProcessingException import javax.ws.rs.ProcessingException
/** /**
* Publisher is the class responsible for implementing the *actual* HTTP * Publisher is the class responsible for implementing the *actual* HTTP
* request logic for Whoas * request logic for Whoas
@ -40,6 +41,7 @@ class Publisher {
Invocation inv = buildInvocationFrom(request) Invocation inv = buildInvocationFrom(request)
try { try {
response = inv.invoke() response = inv.invoke()
/* LOG: response */ /* LOG: response */
String responseBody = response.readEntity(String.class) String responseBody = response.readEntity(String.class)
} }
@ -66,6 +68,10 @@ class Publisher {
* Determine whether this response meets our criteria for retry * Determine whether this response meets our criteria for retry
*/ */
Boolean shouldRetry(Response response) { Boolean shouldRetry(Response response) {
if (response == null) {
return true
}
/* Enhance your calm and try again */ /* Enhance your calm and try again */
if (response.status == 420) { if (response.status == 420) {
return true return true

View File

@ -13,7 +13,7 @@ public class WhoasFactory {
/** /**
* Queue configuration * Queue configuration
*/ */
@JsonProperty @JsonProperty(value = "queue")
WhoasQueueConfig queueConfig = new WhoasQueueConfig() WhoasQueueConfig queueConfig = new WhoasQueueConfig()
/** /**