Skip to content

Commit

Permalink
sonarlint :: add end condition to while loop in PickUpPlace
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdahlke committed May 24, 2024
1 parent 906d8c0 commit b6298ca
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/main/java/emissary/pickup/PickUpPlace.java
Original file line number Diff line number Diff line change
Expand Up @@ -584,16 +584,18 @@ public int processSessions(File theFile, String fixedName) throws IOException, P
SessionParser sp = parserFactory.makeSessionParser(raf.getChannel());
logger.debug("Using session parser from raf ident {}", sp.getClass().getName());

// .. and a session producer to crank out the data objects...
// ... and a session producer to crank out the data objects...
SessionProducer dof = new SessionProducer(sp, myKey, null);

long fileStart = System.currentTimeMillis();
long totalSize = 0;

// For each session get a data object from the producer
while (true) {
boolean isParserComplete = false;
while (!isParserComplete) {
long sessionStart = System.currentTimeMillis();
try {
// Use filename-xx for defualt name
// Use filename-xx for default name
String sessionName = fixedName + "-" + (sessionNum + 1);

IBaseDataObject dataObject = dof.getNextSession(sessionName);
Expand All @@ -606,15 +608,14 @@ public int processSessions(File theFile, String fixedName) throws IOException, P
processDataObject(dataObject, sessionName, theFile, false);
} catch (ParserEOFException eof) {
// expected at end of file
isParserComplete = true;
long fileEnd = System.currentTimeMillis();
logger.info("fileParseMetric:{},{},{},{},{}", fileEnd - fileStart, sp.getClass().getName(), theFile, sessionNum, totalSize);
break;
} catch (EmissaryException ex) {
logger.error("Could not dispatch {}", theFile.getName(), ex);
throw new ParserException("Could not process" + theFile.getName(), ex);
}

} // end while(true)
}
}

logger.debug("Done processing {} sessions from {}", sessionNum, theFile.getName());
Expand Down Expand Up @@ -642,7 +643,8 @@ public int processSessions(byte[] data, String fixedName, File theFile) {
SessionProducer dof = new SessionProducer(sp, myKey, null);

// For each session get a data object from the producer
while (true) {
boolean isParserComplete = false;
while (!isParserComplete) {
try {
// Use filename-xx for default name
String sessionName = fixedName + "-" + (sessionNum + 1);
Expand All @@ -652,12 +654,11 @@ public int processSessions(byte[] data, String fixedName, File theFile) {
processDataObject(dataObject, sessionName, theFile, false);
} catch (ParserEOFException eof) {
// expected at end of file
break;
isParserComplete = true;
} catch (EmissaryException ex) {
logger.error("Could not dispatch {}", fixedName, ex);
}

} // end while(true)
}

logger.debug("Done processing {} sessions from {}", sessionNum, theFile.getName());
return sessionNum;
Expand Down

0 comments on commit b6298ca

Please sign in to comment.