Code Review
/
dmaap
/
messagerouter
/
msgrtr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
fixes for sonar vulnerabilities
[dmaap/messagerouter/msgrtr.git]
/
src
/
main
/
java
/
com
/
att
/
dmf
/
mr
/
metrics
/
publisher
/
impl
/
DMaaPCambriaSimplerBatchPublisher.java
diff --git
a/src/main/java/com/att/dmf/mr/metrics/publisher/impl/DMaaPCambriaSimplerBatchPublisher.java
b/src/main/java/com/att/dmf/mr/metrics/publisher/impl/DMaaPCambriaSimplerBatchPublisher.java
index
d8d8799
..
e9b1cdb
100644
(file)
--- a/
src/main/java/com/att/dmf/mr/metrics/publisher/impl/DMaaPCambriaSimplerBatchPublisher.java
+++ b/
src/main/java/com/att/dmf/mr/metrics/publisher/impl/DMaaPCambriaSimplerBatchPublisher.java
@@
-25,6
+25,7
@@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
+import java.nio.channels.NotYetConnectedException;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@
-123,7
+124,12
@@
public class DMaaPCambriaSimplerBatchPublisher extends CambriaBaseClient
try {
return new DMaaPCambriaSimplerBatchPublisher(fUrls, fTopic, fMaxBatchSize, fMaxBatchAgeMs, fCompress);
} catch (MalformedURLException e) {
try {
return new DMaaPCambriaSimplerBatchPublisher(fUrls, fTopic, fMaxBatchSize, fMaxBatchAgeMs, fCompress);
} catch (MalformedURLException e) {
- throw new RuntimeException(e);
+
+ NotYetConnectedException exception=new NotYetConnectedException();
+ exception.setStackTrace(e.getStackTrace());
+
+ throw exception ;
+
}
}
}
}
@@
-186,7
+192,7
@@
public class DMaaPCambriaSimplerBatchPublisher extends CambriaBaseClient
public void close() {
try {
final List<message> remains = close(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
public void close() {
try {
final List<message> remains = close(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
- if (remains.
size() > 0
) {
+ if (remains.
isEmpty()
) {
getLog().warn("Closing publisher with " + remains.size() + " messages unsent. "
+ "Consider using CambriaBatchingPublisher.close( long timeout, TimeUnit timeoutUnits ) to recapture unsent messages on close.");
}
getLog().warn("Closing publisher with " + remains.size() + " messages unsent. "
+ "Consider using CambriaBatchingPublisher.close( long timeout, TimeUnit timeoutUnits ) to recapture unsent messages on close.");
}
@@
-251,7
+257,7
@@
public class DMaaPCambriaSimplerBatchPublisher extends CambriaBaseClient
*/
private synchronized boolean shouldSendNow() {
boolean shouldSend = false;
*/
private synchronized boolean shouldSendNow() {
boolean shouldSend = false;
- if (fPending.
size() > 0
) {
+ if (fPending.
isEmpty()
) {
final long nowMs = Clock.now();
shouldSend = (fPending.size() >= fMaxBatchSize);
final long nowMs = Clock.now();
shouldSend = (fPending.size() >= fMaxBatchSize);
@@
-273,7
+279,7
@@
public class DMaaPCambriaSimplerBatchPublisher extends CambriaBaseClient
private synchronized boolean sendBatch() {
// it's possible for this call to be made with an empty list. in this
// case, just return.
private synchronized boolean sendBatch() {
// it's possible for this call to be made with an empty list. in this
// case, just return.
- if (fPending.
size() < 1
) {
+ if (fPending.
isEmpty()
) {
return true;
}
return true;
}
@@
-305,8
+311,8
@@
public class DMaaPCambriaSimplerBatchPublisher extends CambriaBaseClient
// code from REST Client Starts
// code from REST Client Starts
- // final String serverCalculatedSignature = sha1HmacSigner.sign
- // ("2015-09-21T11:38:19-0700", "iHAxArrj6Ve9JgmHvR077QiV");
+
+
Client client = ClientBuilder.newClient();
String metricTopicname = AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,"metrics.send.cambria.topic");
Client client = ClientBuilder.newClient();
String metricTopicname = AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,"metrics.send.cambria.topic");
@@
-323,32
+329,19
@@
public class DMaaPCambriaSimplerBatchPublisher extends CambriaBaseClient
Entity<byte[]> data = Entity.entity(baseStream.toByteArray(), "application/cambria");
Response response = target.request().post(data);
Entity<byte[]> data = Entity.entity(baseStream.toByteArray(), "application/cambria");
Response response = target.request().post(data);
- // header("X-CambriaAuth",
- // "2OH46YIWa329QpEF:"+serverCalculatedSignature).
- // header("X-CambriaDate", "2015-09-21T11:38:19-0700").
- // post(Entity.json(baseStream.toByteArray()));
-
+
getLog().info("Response received :: " + response.getStatus());
getLog().info("Response received :: " + response.toString());
// code from REST Client Ends
getLog().info("Response received :: " + response.getStatus());
getLog().info("Response received :: " + response.toString());
// code from REST Client Ends
- /*
- * final JSONObject result = post ( url, contentType,
- * baseStream.toByteArray(), true ); final String logLine =
- * "cambria reply ok (" + (Clock.now()-startMs) + " ms):" +
- * result.toString (); getLog().info ( logLine );
- */
+
fPending.clear();
return true;
} catch (IllegalArgumentException x) {
getLog().warn(x.getMessage(), x);
}
fPending.clear();
return true;
} catch (IllegalArgumentException x) {
getLog().warn(x.getMessage(), x);
}
- /*
- * catch ( HttpObjectNotFoundException x ) { getLog().warn (
- * x.getMessage(), x ); } catch ( HttpException x ) { getLog().warn (
- * x.getMessage(), x ); }
- */
+
catch (IOException x) {
getLog().warn(x.getMessage(), x);
}
catch (IOException x) {
getLog().warn(x.getMessage(), x);
}