[LANG-1544] MethodUtils.invokeMethod NullPointerException in case of null in args list (#680)

* LANG-1544:
- Null guards in place to handle one or more nulls specified as one of the parameters of the method to invoke.
- Check for an exact match of the actual parameter types against all of the methods on the class. This prevents picking an "upcasted" method (i.e. int specified but a method with a double is chosen).
- Throw an IllegalStateException with a helpful message if multiple candidate methods were found. This happens when multiple Methods had the same "distance" from the desired parameter types. Before this change the algorithm would just chose the first one.
- Tests for the above.

Co-authored-by: mike.buck@pb.com <mike.buck@pb.com>
2 files changed
tree: 7fe3a7199922c07f2ac92ce1e030d855aaa4dd50
  1. .github/
  2. src/
  3. .gitattributes
  4. .gitignore
  5. .travis.yml
  6. CONTRIBUTING.md
  7. Jenkinsfile
  8. LICENSE.txt
  9. NOTICE.txt
  10. pom.xml
  11. README.md
  12. RELEASE-NOTES.txt
  13. SECURITY.md
  14. spotbugs-exclude-filter.xml
README.md

Apache Commons Lang

Build Status Coverage Status Maven Central Javadocs

Apache Commons Lang, a package of Java utility classes for the classes that are in java.lang's hierarchy, or are considered to be so standard as to justify existence in java.lang.

Documentation

More information can be found on the Apache Commons Lang homepage. The Javadoc can be browsed. Questions related to the usage of Apache Commons Lang should be posted to the user mailing list.

Where can I get the latest release?

You can download source and binaries from our download page.

Alternatively you can pull it from the central Maven repositories:

<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-lang3</artifactId>
  <version>3.11</version>
</dependency>

Contributing

We accept Pull Requests via GitHub. The developer mailing list is the main channel of communication for contributors. There are some guidelines which will make applying PRs easier for us:

  • No tabs! Please use spaces for indentation.
  • Respect the code style.
  • Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
  • Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running mvn clean test.

If you plan to contribute on a regular basis, please consider filing a contributor license agreement. You can learn more about contributing via GitHub in our contribution guidelines.

License

This code is under the Apache Licence v2.

See the NOTICE.txt file for required notices and attributions.

Donations

You like Apache Commons Lang? Then donate back to the ASF to support the development.

Additional Resources