Skip to content

Commit b47e38c

Browse files
authored
Merge pull request #4782 from gchq/gh-4781
#4781 Fix NPE
2 parents 1d7646c + 93dda41 commit b47e38c

File tree

3 files changed

+58
-27
lines changed

3 files changed

+58
-27
lines changed

stroom-core-client/src/main/java/stroom/dashboard/client/DashboardPlugin.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -167,25 +167,26 @@ private void reopen(final ResultStoreInfo resultStoreInfo) {
167167
final SearchRequestSource source = resultStoreInfo.getSearchRequestSource();
168168
if (source != null && SourceType.DASHBOARD_UI.equals(source.getSourceType())) {
169169
final DocRef docRef = source.getOwnerDocRef();
170-
171-
// If the item isn't already open but we are forcing it open then,
172-
// create a new presenter and register it as open.
173-
final DashboardSuperPresenter presenter = dashboardSuperPresenterProvider.get();
174-
presenter.setResultStoreInfo(resultStoreInfo);
175-
176-
// Load the document and show the tab.
177-
final CloseContentEvent.Handler closeHandler = event -> {
178-
// Tell the presenter we are closing.
179-
presenter.onClose();
180-
// Actually close the tab.
181-
event.getCallback().closeTab(true);
182-
};
183-
showDocument(docRef,
184-
presenter,
185-
closeHandler,
186-
presenter,
187-
false,
188-
new DefaultTaskMonitorFactory(this));
170+
if (docRef != null) {
171+
// If the item isn't already open but we are forcing it open then,
172+
// create a new presenter and register it as open.
173+
final DashboardSuperPresenter presenter = dashboardSuperPresenterProvider.get();
174+
presenter.setResultStoreInfo(resultStoreInfo);
175+
176+
// Load the document and show the tab.
177+
final CloseContentEvent.Handler closeHandler = event -> {
178+
// Tell the presenter we are closing.
179+
presenter.onClose();
180+
// Actually close the tab.
181+
event.getCallback().closeTab(true);
182+
};
183+
showDocument(docRef,
184+
presenter,
185+
closeHandler,
186+
presenter,
187+
false,
188+
new DefaultTaskMonitorFactory(this));
189+
}
189190
}
190191
}
191192

stroom-dashboard/stroom-dashboard-impl/src/main/java/stroom/dashboard/impl/DashboardServiceImpl.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,18 @@ private String getResultsFilename(final DownloadSearchResultsRequest request) {
365365

366366
private String getQueryFileName(final DashboardSearchRequest request) {
367367
final SearchRequestSource searchRequestSource = request.getSearchRequestSource();
368-
final DocRefInfo dashDocRefInfo = dashboardStore.info(searchRequestSource.getOwnerDocRef());
369-
final String dashboardName = NullSafe.getOrElse(
370-
dashDocRefInfo,
371-
DocRefInfo::getDocRef,
372-
DocRef::getName,
373-
searchRequestSource.getOwnerDocRef().getName());
374-
final String basename = dashboardName + "__" + searchRequestSource.getComponentId();
368+
String basename = searchRequestSource.getComponentId();
369+
if (searchRequestSource.getOwnerDocRef() != null) {
370+
final DocRefInfo dashDocRefInfo = dashboardStore.info(searchRequestSource.getOwnerDocRef());
371+
final String dashboardName = NullSafe.getOrElse(
372+
dashDocRefInfo,
373+
DocRefInfo::getDocRef,
374+
DocRef::getName,
375+
searchRequestSource.getOwnerDocRef().getName());
376+
if (dashboardName != null) {
377+
basename = dashboardName + "__" + searchRequestSource.getComponentId();
378+
}
379+
}
375380
return getFileName(basename, "json");
376381
}
377382

@@ -504,7 +509,8 @@ private void storeSearchHistory(final DashboardSearchRequest request) {
504509
final SearchRequestSource searchRequestSource = request.getSearchRequestSource();
505510
final StoredQuery storedQuery = new StoredQuery();
506511
storedQuery.setName("History");
507-
storedQuery.setDashboardUuid(searchRequestSource.getOwnerDocRef().getUuid());
512+
storedQuery.setDashboardUuid(NullSafe
513+
.get(searchRequestSource, SearchRequestSource::getOwnerDocRef, DocRef::getUuid));
508514
storedQuery.setComponentId(searchRequestSource.getComponentId());
509515
storedQuery.setQuery(query);
510516
queryService.create(storedQuery);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
* Issue **#4781** : Fix NPE.
2+
3+
4+
```sh
5+
# ********************************************************************************
6+
# Issue title: Broken API compatability
7+
# Issue link: https://github.com/gchq/stroom/issues/4781
8+
# ********************************************************************************
9+
10+
# ONLY the top line will be included as a change entry in the CHANGELOG.
11+
# The entry should be in GitHub flavour markdown and should be written on a SINGLE
12+
# line with no hard breaks. You can have multiple change files for a single GitHub issue.
13+
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than
14+
# 'Fixed nasty bug'.
15+
#
16+
# Examples of acceptable entries are:
17+
#
18+
#
19+
# * Issue **123** : Fix bug with an associated GitHub issue in this repository
20+
#
21+
# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository
22+
#
23+
# * Fix bug with no associated GitHub issue.
24+
```

0 commit comments

Comments
 (0)