コード例 #1
0
ファイル: LogglyHandler.java プロジェクト: esfand/logging
 @Override
 public void run() {
   HttpEntity entity = null;
   try {
     HttpPost post = new HttpPost(inputUrl);
     StringWriter writer = new StringWriter();
     OM.writeValue(writer, map);
     post.setEntity(new StringEntity(writer.toString()));
     post.setHeader("Content-Type", "application/x-www-form-urlencoded");
     HttpResponse response = httpClient.execute(post);
     entity = response.getEntity();
     statusCode = response.getStatusLine().getStatusCode();
     if (statusCode != 200) {
       if (allowRetry) {
         retryCount++;
         retryQueue.offer(this);
       }
     }
   } catch (Exception e) {
     if (allowRetry) {
       exception = e;
       retryCount++;
       retryQueue.offer(this);
     }
   } finally {
     if (entity != null) {
       try {
         entity.consumeContent();
       } catch (IOException e) {
         // safe to ignore
       }
     }
   }
 }