Skip to content

Commit

Permalink
Fix possible NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed May 31, 2023
1 parent ba3d351 commit 26ee15a
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1033,11 1033,13 @@ private org.apache.maven.api.model.Model doReadFileModel(

if (source != null) {
try {
org.apache.maven.api.model.InputSource v4src =
model.getLocation("").getSource();
Field field = InputSource.class.getDeclaredField("modelId");
field.setAccessible(true);
field.set(v4src, ModelProblemUtils.toId(model));
org.apache.maven.api.model.InputLocation loc = model.getLocation("");
org.apache.maven.api.model.InputSource v4src = loc != null ? loc.getSource() : null;
if (v4src != null) {
Field field = InputSource.class.getDeclaredField("modelId");
field.setAccessible(true);
field.set(v4src, ModelProblemUtils.toId(model));
}
} catch (Throwable t) {
// TODO: use a lazy source ?
throw new IllegalStateException("Unable to set modelId on InputSource", t);
Expand Down

0 comments on commit 26ee15a

Please sign in to comment.