Skip to content

Commit

Permalink
Fix NPE in PluginContext.toBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
JordonPhillips committed Nov 6, 2023
1 parent 0fc277a commit e015c0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,17 @@ private int findOffsetFromStart(String location) {

@Override
public Builder toBuilder() {
return builder()
.projection(projectionName, projection)
Builder builder = builder()
.model(model)
.originalModel(originalModel)
.events(events)
.settings(settings)
.fileManifest(fileManifest)
.pluginClassLoader(pluginClassLoader)
.sources(sources)
.artifactName(artifactName);
getProjection().ifPresent(config -> builder.projection(projectionName, config));
getOriginalModel().ifPresent(builder::originalModel);
return builder;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,16 @@ public void convertsToBuilder() {
assertThat(context.getSources(), equalTo(context2.getSources()));
assertThat(context.getEvents(), equalTo(context2.getEvents()));
}

@Test
public void roundTripsDefaults() {
PluginContext before = PluginContext.builder()
.model(Model.builder().build())
.fileManifest(new MockManifest())
.build();
PluginContext after = before.toBuilder().build();
assertThat(before.getModel(), equalTo(after.getModel()));
assertThat(before.getFileManifest(), equalTo(after.getFileManifest()));
assertThat(before.getProjectionName(), equalTo(after.getProjectionName()));
}
}

0 comments on commit e015c0f

Please sign in to comment.