Removing code smells
[dmaap/datarouter.git] / datarouter-node / src / main / java / org / onap / dmaap / datarouter / node / DeliveryTask.java
index 91bd716..eb79b56 100644 (file)
@@ -94,9 +94,9 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
         this.followRedirects = destInfo.isFollowRedirects();
         feedid = destInfo.getLogData();
         spool = destInfo.getSpool();
-        String dfn = spool + "/" + pubid;
+        String dfn = spool + File.separator + pubid;
         String mfn = dfn + ".M";
-        datafile = new File(spool + "/" + pubid);
+        datafile = new File(spool + File.separator + pubid);
         metafile = new File(mfn);
         boolean monly = destInfo.isMetaDataOnly();
         date = Long.parseLong(pubid.substring(0, pubid.indexOf('.')));
@@ -222,6 +222,7 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
             byte[] buf = new byte[4096];
             if (is != null) {
                 while (is.read(buf) > 0) {
+                    //flush the buffer
                 }
                 is.close();
             }
@@ -242,7 +243,7 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
         httpURLConnection.setRequestProperty(DECOMPRESSION_STATUS, "SUCCESS");
         OutputStream outputStream = getOutputStream(httpURLConnection);
         if (outputStream != null) {
-            int bytesRead = 0;
+            int bytesRead;
             try (InputStream gzipInputStream = new GZIPInputStream(new FileInputStream(datafile))) {
                 int bufferLength = buffer.length;
                 while ((bytesRead = gzipInputStream.read(buffer, 0, bufferLength)) > 0) {
@@ -296,7 +297,7 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
      * @param httpURLConnection connection used to make request
      * @return AN Outpustream that can be used to send your data.
      */
-    private OutputStream getOutputStream(HttpURLConnection httpURLConnection) throws IOException {
+    OutputStream getOutputStream(HttpURLConnection httpURLConnection) throws IOException {
         OutputStream outputStream = null;
         try {
             outputStream = httpURLConnection.getOutputStream();
@@ -371,7 +372,8 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
                 Files.deleteIfExists(file.toPath());
                 break;
             } catch (IOException e) {
-                eelfLogger.error("IOException : Failed to delete file :" + file.getName() + " on attempt " + tryCount, e);
+                eelfLogger.error("IOException : Failed to delete file :"
+                                         + file.getName() + " on attempt " + tryCount, e);
             }
             tryCount++;
         }
@@ -464,7 +466,7 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
     /**
      * Get the followRedirects for this delivery task.
      */
-    public boolean getFollowRedirects() {
+    boolean getFollowRedirects() {
         return (followRedirects);
     }
 }