|
33 | 33 | import java.io.InputStream;
|
34 | 34 | import java.io.OutputStreamWriter;
|
35 | 35 | import java.io.Writer;
|
| 36 | +import java.net.ConnectException; |
36 | 37 | import java.nio.file.Files;
|
37 | 38 | import java.nio.file.Path;
|
38 | 39 | import java.nio.file.Paths;
|
@@ -354,27 +355,38 @@ private void markProjectIndexed(Project project) {
|
354 | 355 | // Successfully indexed the project. The message is sent even if
|
355 | 356 | // the project's isIndexed() is true because it triggers RepositoryInfo
|
356 | 357 | // refresh.
|
357 |
| - if (project != null) { |
358 |
| - // Also need to store the correct value in configuration |
359 |
| - // when indexer writes it to a file. |
360 |
| - project.setIndexed(true); |
361 |
| - |
362 |
| - if (env.getConfigURI() != null) { |
363 |
| - Response r = ClientBuilder.newClient() |
364 |
| - .target(env.getConfigURI()) |
365 |
| - .path("api") |
366 |
| - .path("v1") |
367 |
| - .path("projects") |
368 |
| - .path(Util.URIEncode(project.getName())) |
369 |
| - .path("indexed") |
370 |
| - .request() |
371 |
| - .put(Entity.text("")); |
372 |
| - |
373 |
| - if (r.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) { |
374 |
| - LOGGER.log(Level.WARNING, "Couldn''t notify the webapp that project {0} was indexed: {1}", |
375 |
| - new Object[] {project, r}); |
376 |
| - } |
377 |
| - } |
| 358 | + if (project == null) { |
| 359 | + return; |
| 360 | + } |
| 361 | + |
| 362 | + // Also need to store the correct value in configuration |
| 363 | + // when indexer writes it to a file. |
| 364 | + project.setIndexed(true); |
| 365 | + |
| 366 | + if (env.getConfigURI() == null) { |
| 367 | + return; |
| 368 | + } |
| 369 | + |
| 370 | + Response r; |
| 371 | + try { |
| 372 | + r = ClientBuilder.newClient() |
| 373 | + .target(env.getConfigURI()) |
| 374 | + .path("api") |
| 375 | + .path("v1") |
| 376 | + .path("projects") |
| 377 | + .path(Util.URIEncode(project.getName())) |
| 378 | + .path("indexed") |
| 379 | + .request() |
| 380 | + .put(Entity.text("")); |
| 381 | + } catch (RuntimeException e) { |
| 382 | + LOGGER.log(Level.WARNING, "Couldn''t notify the webapp that project {0} was indexed: {1}", |
| 383 | + new Object[] {project, e}); |
| 384 | + return; |
| 385 | + } |
| 386 | + |
| 387 | + if (r.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) { |
| 388 | + LOGGER.log(Level.WARNING, "Couldn''t notify the webapp that project {0} was indexed: {1}", |
| 389 | + new Object[] {project, r}); |
378 | 390 | }
|
379 | 391 | }
|
380 | 392 |
|
|
0 commit comments