Skip to content
Snippets Groups Projects
Commit ae96e602 authored by Danny van Heumen's avatar Danny van Heumen
Browse files

Gracefully handle race (NPE)

parent 86d38051
No related tags found
No related merge requests found
......@@ -2107,11 +2107,21 @@ private ReplacementWorker(final String messageID,
@Override
public void finished()
{
ShowPreviewDialog previewDialog = showPreview;
// There is a race between the replacement worker and the
// ChatConversationPanel when it is (being) disposed of. Make sure
// we have an instance before continuing.
if (previewDialog == null)
{
// Abort if dialog has been disposed of.
return;
}
String newMessage = (String) get();
if (newMessage != null && !newMessage.equals(chatString))
{
showPreview.getMsgIDToChatString().put(
previewDialog.getMsgIDToChatString().put(
messageID, newMessage);
synchronized (scrollToBottomRunnable)
{
......@@ -2229,6 +2239,16 @@ private void processText(final String plainText,
final ReplacementService rService,
final boolean isURL)
{
final ShowPreviewDialog previewDialog = showPreview;
// There is a race between the replacement worker and the
// ChatConversationPanel when it is (being) disposed of. Make sure
// we have an instance before continuing.
if (previewDialog == null)
{
// Abort if dialog has been disposed of.
return;
}
Matcher m = pattern.matcher(plainText);
ConfigurationService cfg = GuiActivator.getConfigurationService();
......@@ -2276,7 +2296,7 @@ else if (isProposalEnabled)
{
msgBuff.append(StringEscapeUtils.escapeHtml4(group));
msgBuff.append("</A> <A href=\"jitsi://"
+ showPreview.getClass().getName()
+ previewDialog.getClass().getName()
+ "/SHOWPREVIEW?" + messageID
+ "#"
+ linkCounter
......@@ -2285,12 +2305,10 @@ else if (isProposalEnabled)
.getResources().getI18NString(
"service.gui.SHOW_PREVIEW")));
showPreview.getMsgIDandPositionToLink()
.put(
messageID + "#" + linkCounter++, group);
showPreview.getLinkToReplacement()
.put(
group, temp);
previewDialog.getMsgIDandPositionToLink()
.put(messageID + "#" + linkCounter++, group);
previewDialog.getLinkToReplacement()
.put(group, temp);
}
else if (isEnabled && isEnabledForSource)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment