Skip to content
This repository was archived by the owner on Jan 11, 2019. It is now read-only.

Commit 812793c

Browse files
author
Ole Lensmar
authored
Merge pull request #39 from VladimirSB/SOAP-5313-Cannot-invoke-method-addNewInterface()-on-null-object-error-when-cancel-project-creating
SOAP-5313 "Cannot invoke method addNewInterface() on null object" error when cancel project creating
2 parents 55183b9 + f0d66c8 commit 812793c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/groovy/com/smartbear/swagger/Swagger2Importer.groovy

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class Swagger2Importer implements SwaggerImporter {
117117
}
118118

119119
void ensureEndpoint(RestService restService, String url) {
120-
if (restService.endpoints.length == 0) {
120+
if (restService != null && restService.endpoints.length == 0) {
121121

122122
def ix = url.indexOf("://")
123123
if (ix > 0) {
@@ -136,6 +136,9 @@ class Swagger2Importer implements SwaggerImporter {
136136
*/
137137

138138
RestResource importPath(RestService restService, String path, Path resource) {
139+
if (restService == null) {
140+
return null
141+
}
139142
RestResource res = restService.addNewResource(path, path)
140143

141144
if (resource.get != null)
@@ -300,6 +303,9 @@ class Swagger2Importer implements SwaggerImporter {
300303
}
301304

302305
private RestService createRestService(Swagger swagger, String url) {
306+
if (project == null) {
307+
return null
308+
}
303309

304310
String name = swagger.info && swagger.info.title ? swagger.info.title : null
305311
if (name == null) {
@@ -311,9 +317,7 @@ class Swagger2Importer implements SwaggerImporter {
311317
}
312318
}
313319

314-
RestService restService = forRefactoring ?
315-
InterfaceFactoryRegistry.createNew(project, RestServiceFactory.REST_TYPE, name) :
316-
project.addNewInterface(name, RestServiceFactory.REST_TYPE)
320+
RestService restService = project.addNewInterface(name, RestServiceFactory.REST_TYPE);
317321
restService.description = swagger.info?.description
318322

319323
if (swagger.host != null) {

0 commit comments

Comments
 (0)