RFR: 7903964: Fix NPE in JTRegConfiguration.getJDKString [v2]

Oleksii Sylichenko duke at openjdk.org
Fri Mar 7 16:51:27 UTC 2025


> # This bug appears when
> - The user removes the "Build" target from "Before launch" in the Run Configuration.
> - The user unsets or does not set the Project SDK, or if it has been removed from the file system.
> 
> # Steps to reproduce
> 
> 1. Open a JDK project.
> 2. Open "Project Structure".
> 3. Select an SDK in the Project tab.
> 4. Navigate to "Settings → jtreg".
> 5. Set "JRE = "Default".
> 6. Run a test to automatically create a run configuration, or manually create one with "JRE = Default".
> 7. Open Project Structure again.
> 8. Set SDK = "<No SDK>".
> 9. Edit the previously created Run Configuration and remove the "Build" target from "Before launch".
> 10. Run the previously created Run Configuration.
> 
> ## Expected
> - Error message appeared: "No valid JDK configured for running jtreg tests"
> 
> ## Actual:
> - Nothing happened
> 
> # Implemented Changes
> 
> ## JTRegConfiguration.java
> - Add the `@NotNull` annotation to methods that are missing it but have it in the parent method.
> - Add javadoc to `getJDKString`.
> - Refactor `getJDKString`:
>   - Fix method getJDKString, to prevent NPE when Default SDK for the project was not set
> 
> ## JTRegConfigurationRunnableState.java
> - Change visibility to `public` to eliminate the warning in `JTRegConfiguration#getState`.

Oleksii Sylichenko has updated the pull request incrementally with one additional commit since the last revision:

  7903964: Fix NPE in JTRegConfiguration.getJDKString
  - remove `final` from local variables

-------------

Changes:
  - all: https://git.openjdk.org/jtreg/pull/251/files
  - new: https://git.openjdk.org/jtreg/pull/251/files/95271cb0..c0ade713

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jtreg&pr=251&range=01
 - incr: https://webrevs.openjdk.org/?repo=jtreg&pr=251&range=00-01

  Stats: 4 lines in 1 file changed: 0 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jtreg/pull/251.diff
  Fetch: git fetch https://git.openjdk.org/jtreg.git pull/251/head:pull/251

PR: https://git.openjdk.org/jtreg/pull/251


More information about the jtreg-dev mailing list