26
26
import java .sql .ResultSet ;
27
27
import java .sql .SQLException ;
28
28
import java .sql .Statement ;
29
+ import java .util .NoSuchElementException ;
29
30
import java .util .logging .Level ;
30
31
import java .util .logging .Logger ;
31
32
32
33
public class WebDispatcherLogRead {
33
34
34
- Logger LOGGER ;// = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
35
+ Logger LOGGER ;
35
36
String MetricRootProperty ;
36
37
37
- /*private void setUpLogger(){
38
- try{
39
- FileHandler fileTxt = new FileHandler("webDispatcher.log", 1000000, 5, true);
40
- fileTxt.setFormatter(new SimpleFormatter());
41
- LOGGER.addHandler(fileTxt);
42
- }
43
- catch (IOException e){
44
- LOGGER.log(Level.WARNING, "Unable to write log: {0}", e.getMessage());
45
- }
46
- }*/
47
-
48
38
public WebDispatcherLogRead (String MetricRoot ){
49
39
LOGGER = Logger .getLogger (Logger .GLOBAL_LOGGER_NAME );
50
40
MetricRootProperty = MetricRoot ;
@@ -352,7 +342,21 @@ public void processFile(Path path, Long initialPosition, ConfigReader configurat
352
342
try {
353
343
if ((rotated == true )&&(!configuration .getPropValues ("read.properties" ).get ("last_position" ).equals ("0" ))){
354
344
try (Stream <String > lineChecker = Files .lines (path )) {
355
- newLine = lineChecker .skip (initialPosition ).findFirst ().get ();
345
+ /*boolean empty_line = true;
346
+ int empty_line_counter = 0;
347
+ while (empty_line){*/
348
+ try {
349
+ newLine = lineChecker .skip (initialPosition ).findFirst ().get ();
350
+ //empty_line = false;
351
+
352
+ }
353
+ catch (NoSuchElementException nse ){
354
+ LOGGER .log (Level .INFO , "Found an empty line, ignoring and moving on." );
355
+ /*empty_line_counter++;
356
+ initialPosition+=empty_line_counter;
357
+ empty_line = true;*/
358
+ }
359
+ //}
356
360
if (!newLine .equals (configuration .getPropValues ("read.properties" ).get ("last_line_contents" ))){
357
361
return ;
358
362
}
@@ -374,7 +378,12 @@ public void processFile(Path path, Long initialPosition, ConfigReader configurat
374
378
while (moreLineExist ) {
375
379
try (Stream <String > lines = Files .lines (path )) {
376
380
//i++;
377
- newLine = lines .skip (initialPosition +i +1 ).findFirst ().get ();
381
+ //try{
382
+ newLine = lines .skip (initialPosition +i +1 ).findFirst ().get ();
383
+ //}
384
+ //catch(NoSuchElementException nse){
385
+ // LOGGER.log(Level.INFO, "Found an empty line, checking nexy line");
386
+ //}
378
387
i ++;
379
388
processLine (newLine , bd , h2con );
380
389
0 commit comments