Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch order of literals to prevent NullPointerException #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions ncdssdk-client/src/main/java/com/nasdaq/ncdsclient/NCDSSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public static void main(String[] args) throws Exception {
NCDSClient ncdsClient = null;

try {
if (testOption.equals("TOP")) {
if ("TOP".equals(testOption)) {
ncdsClient = new NCDSClient(securityCfg,kafkaConfig);
int numOfRecords = Math.min(Integer.parseInt(numberOfTopMessage),999);
if (numOfRecords == 0) {
Expand Down Expand Up @@ -194,7 +194,7 @@ public static void main(String[] args) throws Exception {
System.out.println("Access to topic is not granted ");
}
}
else if (testOption.equals("METRICS")) {
else if ("METRICS".equals(testOption)) {
ncdsClient = new NCDSClient(securityCfg,kafkaConfig);
Map<MetricName, ? extends Metric> metrics = ncdsClient.getMetrics(topic);
System.out.println("Retrieve the Metrics for the Topic:" + topic );
Expand All @@ -203,7 +203,7 @@ else if (testOption.equals("METRICS")) {

}
}
else if (testOption.equals("SCHEMA")) {
else if ("SCHEMA".equals(testOption)) {
ncdsClient = new NCDSClient(securityCfg,kafkaConfig);
// Dump the Schema for the topic
String schema = ncdsClient.getSchemaForTheTopic(topic);
Expand All @@ -215,10 +215,10 @@ else if (testOption.equals("SCHEMA")) {
System.out.println(" Access to topic is not granted ");
}
}
else if (testOption.equals("GETMSG")) {
else if ("GETMSG".equals(testOption)) {
ncdsClient = new NCDSClient(securityCfg,kafkaConfig);
System.out.println("Finding the message");
if (kafkaConfig.containsKey("auto.offset.reset") && kafkaConfig.getProperty("auto.offset.reset").equals("latest")){
if (kafkaConfig.containsKey("auto.offset.reset") && "latest".equals(kafkaConfig.getProperty("auto.offset.reset"))){
System.out.println("Need to get run GETMSG with `earliest` offset");
System.exit(0);
}
Expand All @@ -230,24 +230,24 @@ else if (testOption.equals("GETMSG")) {
System.out.println(" Message Not Found ... ");
}
}
else if (testOption.equals("GETALLMSGS")){
else if ("GETALLMSGS".equals(testOption)){
ncdsClient = new NCDSClient(securityCfg,kafkaConfig);
System.out.println("Finding the messages");
if (kafkaConfig.containsKey("auto.offset.reset") && kafkaConfig.getProperty("auto.offset.reset").equals("latest")){
if (kafkaConfig.containsKey("auto.offset.reset") && "latest".equals(kafkaConfig.getProperty("auto.offset.reset"))){
System.out.println("Need to get run GETMSG with `earliest` offset");
System.exit(0);
}
ncdsClient.getSampleMessages(topic, messageName, true);
}
else if (testOption.equals("TOPICS")){
else if ("TOPICS".equals(testOption)){
ncdsClient = new NCDSClient(securityCfg,kafkaConfig);
String[] topics = ncdsClient.ListTopicsForTheClient();
System.out.println("List of streams available on Nasdaq Cloud DataService:" );
for (String topicEntry : topics) {
System.out.println(topicEntry);
}
}
else if (testOption.equals("NEWS")){
else if ("NEWS".equals(testOption)){
ncdsClient = new NCDSClient(securityCfg,kafkaConfig);
Consumer ncdsmtNewsKafkaConsumer = ncdsClient.NCDSNewsKafkaConsumer(topic);
System.out.println("Now starting the news!!" );
Expand All @@ -273,7 +273,7 @@ else if (testOption.equals("NEWS")){
}

}
else if (testOption.equals("CONTSTREAM")) {
else if ("CONTSTREAM".equals(testOption)) {
ncdsClient = new NCDSClient(securityCfg,kafkaConfig);
Consumer consumer;
if (timestamp == null){
Expand Down Expand Up @@ -301,7 +301,7 @@ else if (testOption.equals("CONTSTREAM")) {
consumer.close();
}
}
else if( testOption.equals("FILTERSTREAM")){
else if( "FILTERSTREAM".equals(testOption)){
Set<String> symbolSet = null;
Set<String> msgTypeSet = null;

Expand Down Expand Up @@ -335,7 +335,7 @@ else if( testOption.equals("FILTERSTREAM")){
if (symbolField != null) {
sym = ((org.apache.avro.util.Utf8) record.value().get(symbolField.pos())).toString().trim();
}
if (msgType != null && !msgType.equals("")) {
if (msgType != null && !"".equals(msgType)) {
msg_t = msgType.trim();
}

Expand Down