Skip to content

Commit 1951da4

Browse files
committed
fixed NPE for mising state
1 parent e8fec2c commit 1951da4

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

jcp-tests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<packaging>pom</packaging>
99

1010
<properties>
11-
<jcp.test.version>7.2.0</jcp.test.version>
11+
<jcp.test.version>7.2.1-SNAPSHOT</jcp.test.version>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1313
<junit.version>5.13.3</junit.version>
1414
<maven.compiler.release>11</maven.compiler.release>

jcp/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.igormaznitsa</groupId>
77
<artifactId>jcp-pom</artifactId>
8-
<version>7.2.0</version>
8+
<version>7.2.1-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>jcp</artifactId>

jcp/src/main/java/com/igormaznitsa/jcp/containers/FileInfoContainer.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,8 @@ public PreprocessingState preprocessFileWithNotification(final PreprocessingStat
510510
}
511511

512512
if (rawString == null) {
513-
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter, state, context);
513+
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter, preprocessingState,
514+
context);
514515
lastTextFileDataContainer = preprocessingState.popTextContainer();
515516
if (preprocessingState.isIncludeStackEmpty()) {
516517
break;
@@ -538,7 +539,8 @@ public PreprocessingState preprocessFileWithNotification(final PreprocessingStat
538539
final boolean doPrintLn = presentedNextLine || !context.isCareForLastEol();
539540

540541
if (isHashPrefixed(stringToBeProcessed, context)) {
541-
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter, state, context);
542+
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter, preprocessingState,
543+
context);
542544
final String extractedDirective =
543545
extractHashPrefixedDirective(stringToBeProcessed, context);
544546
switch (processDirective(preprocessingState, extractedDirective, context, false)) {
@@ -594,12 +596,14 @@ public PreprocessingState preprocessFileWithNotification(final PreprocessingStat
594596
textBlockBuffer.append(context.getEol());
595597
}
596598
} else {
597-
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter, state, context);
599+
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter,
600+
preprocessingState, context);
598601
textBlockBuffer.append(stringPrefix).append(text);
599602
if (doPrintLn) {
600603
textBlockBuffer.append(context.getEol());
601604
}
602-
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter, state, context);
605+
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter,
606+
preprocessingState, context);
603607
}
604608
} else if (isSingleDollarPrefixed(stringToBeProcessed, context.isAllowWhitespaces())) {
605609
// Output the tail of the string to the output stream without comments
@@ -614,16 +618,19 @@ public PreprocessingState preprocessFileWithNotification(final PreprocessingStat
614618
textBlockBuffer.append(context.getEol());
615619
}
616620
} else {
617-
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter, state, context);
621+
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter,
622+
preprocessingState, context);
618623
textBlockBuffer.append(stringPrefix).append(text);
619624
if (doPrintLn) {
620625
textBlockBuffer.append(context.getEol());
621626
}
622-
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter, state, context);
627+
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter,
628+
preprocessingState, context);
623629
}
624630
} else {
625631
// Just string
626-
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter, state, context);
632+
this.flushTextBufferForRemovedComments(textBlockBuffer, thePrinter,
633+
preprocessingState, context);
627634

628635
final String strToOut = findTailRemover(stringToBeProcessed, context);
629636

@@ -642,7 +649,8 @@ public PreprocessingState preprocessFileWithNotification(final PreprocessingStat
642649
}
643650
}
644651
} else if (context.isKeepLines()) {
645-
flushTextBufferForRemovedComments(textBlockBuffer, thePrinter, state, context);
652+
flushTextBufferForRemovedComments(textBlockBuffer, thePrinter, preprocessingState,
653+
context);
646654
final String text = AbstractDirectiveHandler.PREFIX_FOR_KEEPING_LINES + rawString;
647655
if (doPrintLn) {
648656
thePrinter.println(text, context.getEol());

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.igormaznitsa</groupId>
77
<artifactId>jcp-pom</artifactId>
8-
<version>7.2.0</version>
8+
<version>7.2.1-SNAPSHOT</version>
99
<packaging>pom</packaging>
1010

1111
<url>https://github.com/raydac/java-comment-preprocessor</url>

0 commit comments

Comments
 (0)