@@ -100,7 +100,7 @@ public class HttpManager {
100100
101101 private Map <String , InvocationObject > jobs = new HashMap <String , InvocationObject >();
102102
103- public static enum HttpMode {
103+ public enum HttpMode {
104104 SYNC , ASYNC , FIREANDFORGET
105105 }
106106
@@ -117,12 +117,7 @@ public void init() {
117117 ConnectionSocketFactory plainsf = new PlainConnectionSocketFactory ();
118118
119119 // socket factory for HTTPS
120- SSLConnectionSocketFactory sslsf = null ;
121- if (configure .getSslContext () != null ) {
122- sslsf = new SSLConnectionSocketFactory (configure .getSslContext ());
123- } else {
124- sslsf = new SSLConnectionSocketFactory (SSLContexts .createSystemDefault ());
125- }
120+ SSLConnectionSocketFactory sslsf = initSSLConnectionSocketFactory ();
126121
127122 // register socket factories
128123 Registry <ConnectionSocketFactory > r = RegistryBuilder .<ConnectionSocketFactory > create ()
@@ -162,15 +157,16 @@ public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
162157 HeaderElement he = it .nextElement ();
163158 String param = he .getName ();
164159 String value = he .getValue ();
165- if (value != null && param . equalsIgnoreCase ( "timeout" )) {
160+ if (value != null && "timeout" . equalsIgnoreCase ( param )) {
166161 try {
167- return Long .parseLong (value ) * 1000 ;
162+ return Long .parseLong (value ) * 1000L ;
168163 } catch (NumberFormatException ignore ) {
164+ // ignore this exception
169165 }
170166 }
171167 }
172168 // otherwise keep alive for 30 seconds
173- return 30 * 1000 ;
169+ return 30L * 1000L ;
174170 }
175171
176172 };
@@ -404,11 +400,8 @@ private HttpResponseEntity executeInternal(String baseUrl, HttpRequestEntity req
404400 }
405401 }
406402
407- HttpRequestBase request = null ;
403+ HttpRequestBase request ;
408404 switch (requestEntity .type ) {
409- case GET :
410- request = new HttpGet (url );
411- break ;
412405 case POST :
413406 HttpPost post = new HttpPost (url );
414407 configureBodyParams (requestEntity , post );
@@ -430,6 +423,10 @@ private HttpResponseEntity executeInternal(String baseUrl, HttpRequestEntity req
430423 case DELETE :
431424 request = new HttpDelete (url );
432425 break ;
426+ case GET :
427+ default :
428+ request = new HttpGet (url );
429+ break ;
433430 }
434431
435432 // common-header
@@ -468,7 +465,7 @@ private HttpResponseEntity executeInternal(String baseUrl, HttpRequestEntity req
468465 if (configure .isEnableCURLLogger ()) {
469466 CURLLogger .log (url , requestEntity , userAgent , credentials );
470467 }
471- HttpResponse response = null ;
468+ HttpResponse response ;
472469 if (preDefinedResponse != null ) {
473470 return preDefinedResponse ;
474471 }
@@ -624,12 +621,23 @@ public void addJob(String jobId, InvocationObject invocationObject) {
624621 }
625622
626623 public String getLastJobId () {
627- return jobIds .size () == 0 ? null : jobIds .get (jobIds .size () - 1 );
624+ return jobIds .isEmpty () ? null : jobIds .get (jobIds .size () - 1 );
628625 }
629626
630627 public void resetJobs () {
631628 this .jobIds = new ArrayList <String >();
632629 this .jobs .clear ();
633630
634631 }
632+
633+ private SSLConnectionSocketFactory initSSLConnectionSocketFactory () {
634+ SSLConnectionSocketFactory sslsf ;
635+ if (configure .getSslContext () != null ) {
636+ sslsf = new SSLConnectionSocketFactory (configure .getSslContext ());
637+ } else {
638+ sslsf = new SSLConnectionSocketFactory (SSLContexts .createSystemDefault ());
639+ }
640+ return sslsf ;
641+ }
642+
635643}
0 commit comments