X-Git-Url: https://gerrit.onap.org/r/gitweb?p=dmaap%2Fdatarouter.git;a=blobdiff_plain;f=datarouter-node%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fnode%2FDeliveryTask.java;h=eb79b563d37dc75e640ac0f2e7a24c0607626e29;hp=91bd716b53786d377460b2cf011901aa1815a78d;hb=6c78b3e6a0a67c73f931337356a172cc69cee0e8;hpb=8528bac26723e619901f4020848b2cf05538f43d diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java index 91bd716b..eb79b563 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java @@ -94,9 +94,9 @@ public class DeliveryTask implements Runnable, Comparable { 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 { 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 { 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 { * @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 { 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 { /** * Get the followRedirects for this delivery task. */ - public boolean getFollowRedirects() { + boolean getFollowRedirects() { return (followRedirects); } }