From b6298cad42d263a8ff94e65a86a6c679f69e3dae Mon Sep 17 00:00:00 2001 From: Jason Dahlke Date: Fri, 24 May 2024 14:50:40 +0000 Subject: [PATCH] sonarlint :: add end condition to while loop in PickUpPlace --- .../java/emissary/pickup/PickUpPlace.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/emissary/pickup/PickUpPlace.java b/src/main/java/emissary/pickup/PickUpPlace.java index 52110a1ea8..50d5463b46 100755 --- a/src/main/java/emissary/pickup/PickUpPlace.java +++ b/src/main/java/emissary/pickup/PickUpPlace.java @@ -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); @@ -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()); @@ -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); @@ -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;