Avoid FileWriter scheduled task NPE (#205)

[Bug] fileOutputStream in FileWriter has been flushed and cleared when switching to a new file, which causes NPE. 

Fix https://github.com/apache/skywalking/issues/9201
This commit is contained in:
huangjikun 2022-06-11 15:45:33 +08:00 committed by GitHub
parent 372d754030
commit c8840b010c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -23,6 +23,7 @@ Release Notes.
* Fix argument type name of Array in postgresql-8.x-plugin from java.lang.String[] to [Ljava.lang.String;
* Add type name checking in ArgumentTypeNameMatch and ReturnTypeNameMatch
* Highlight ArgumentTypeNameMatch and ReturnTypeNameMatch type naming rule in docs/en/setup/service-agent/java-agent/Java-Plugin-Development-Guide.md
* Fix FileWriter scheduled task NPE
#### Documentation

View File

@ -73,7 +73,9 @@ public class FileWriter implements IWriter {
writeToFile(log + Constants.LINE_SEPARATOR);
}
try {
fileOutputStream.flush();
if (fileOutputStream != null) {
fileOutputStream.flush();
}
} catch (IOException e) {
e.printStackTrace();
}