mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#504 fix potential NPE in StreamEncoder (char-array can be null)
This commit is contained in:
parent
0674a8780b
commit
fb8a6e3ae0
@ -143,22 +143,24 @@ class IndentationCorrectingWriter extends Writer {
|
||||
}
|
||||
|
||||
private void flush(StateContext context) throws IOException {
|
||||
context.writer.write(
|
||||
context.characters,
|
||||
context.lastStateChange,
|
||||
context.currentIndex - context.lastStateChange
|
||||
);
|
||||
|
||||
if ( DEBUG ) {
|
||||
System.out.print(
|
||||
new String(
|
||||
java.util.Arrays.copyOfRange(
|
||||
context.characters,
|
||||
context.lastStateChange,
|
||||
context.currentIndex
|
||||
)
|
||||
)
|
||||
if ( null != context.characters && context.currentIndex - context.lastStateChange > 0 ) {
|
||||
context.writer.write(
|
||||
context.characters,
|
||||
context.lastStateChange,
|
||||
context.currentIndex - context.lastStateChange
|
||||
);
|
||||
|
||||
if ( DEBUG ) {
|
||||
System.out.print(
|
||||
new String(
|
||||
java.util.Arrays.copyOfRange(
|
||||
context.characters,
|
||||
context.lastStateChange,
|
||||
context.currentIndex
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user