mirror of https://github.com/apache/maven.git
Fix possible NPE
This commit is contained in:
parent
ba3d3516eb
commit
26ee15a47e
|
@ -1033,11 +1033,13 @@ public class DefaultModelBuilder implements ModelBuilder {
|
||||||
|
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
try {
|
try {
|
||||||
org.apache.maven.api.model.InputSource v4src =
|
org.apache.maven.api.model.InputLocation loc = model.getLocation("");
|
||||||
model.getLocation("").getSource();
|
org.apache.maven.api.model.InputSource v4src = loc != null ? loc.getSource() : null;
|
||||||
Field field = InputSource.class.getDeclaredField("modelId");
|
if (v4src != null) {
|
||||||
field.setAccessible(true);
|
Field field = InputSource.class.getDeclaredField("modelId");
|
||||||
field.set(v4src, ModelProblemUtils.toId(model));
|
field.setAccessible(true);
|
||||||
|
field.set(v4src, ModelProblemUtils.toId(model));
|
||||||
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
// TODO: use a lazy source ?
|
// TODO: use a lazy source ?
|
||||||
throw new IllegalStateException("Unable to set modelId on InputSource", t);
|
throw new IllegalStateException("Unable to set modelId on InputSource", t);
|
||||||
|
|
Loading…
Reference in New Issue