spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

buildSrc's PluginXmlParser will NPE if a parameter has no description

Open HermioneSW opened this issue 5 years ago • 6 comments

Hi, We are developing a new static analysis tool for catching bugs in Java code. Upon scanning your codebase we find the following:

in PluginXmlParser.java (buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/PluginXmlParser.java ) method parseParameter at line 100. The function call format(textAt("description", parameterNode)) at line 104, textAt could potentially return a null pointer at line 63. Then in function format at line 112, input.replace may trigger a null pointer dereference.

Would you please take a look and confirm this is indeed a bug? Thanks a million!!!

HermioneSW avatar Apr 09 '20 00:04 HermioneSW

Thanks for the report. Yes, in theory it's possible for a NullPointerException to occur when textAt returns null and it's then passed into format where it's dereferenced. In practice, description is always present so the problem won't occur but we should make that clearer in the code.

wilkinsona avatar Apr 09 '20 07:04 wilkinsona

Thanks @wilkinsona for the comment. That helps!

HermioneSW avatar Apr 09 '20 18:04 HermioneSW

Reopening as we still need to do something about this based on Andy's comment above.

mbhave avatar Apr 09 '20 18:04 mbhave

Do you think that returning an empty String at format method, when the parameter is null, is a good solution?

RicardoRFaria avatar Apr 16 '20 12:04 RicardoRFaria

@RicardoRFaria I've edited your comment to remove "guys". While it may seem a small thing, some people feel excluded by "guys" and we don't want them to.

snicoll avatar Apr 16 '20 12:04 snicoll

@snicoll I appreciate your feedback, sorry about that.

RicardoRFaria avatar Apr 16 '20 12:04 RicardoRFaria