From 2769f32da7bc2e7ccdde98f47e0c777769fb9113 Mon Sep 17 00:00:00 2001 From: "rj.keller%beonex.com" Date: Fri, 22 Jul 2005 00:45:28 +0000 Subject: [PATCH] Bug 300464 - If no servers are register, a NullPointerException prevents normal operation. --- grendel/sources/grendel/ui/MasterPanel.java | 21 ++++++++++++++------ grendel/sources/grendel/ui/StoreFactory.java | 12 ++++++----- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/grendel/sources/grendel/ui/MasterPanel.java b/grendel/sources/grendel/ui/MasterPanel.java index 5876a4d5e610..ac80305f0de0 100644 --- a/grendel/sources/grendel/ui/MasterPanel.java +++ b/grendel/sources/grendel/ui/MasterPanel.java @@ -202,9 +202,14 @@ public class MasterPanel extends GeneralPanel { fModel = new FolderModel(); ViewedStore stores[] = StoreFactory.Instance().getStores(); fStores = new ViewedStore[stores.length]; - for (int i = 0; i < stores.length; i++) { - fModel.addStore(stores[i]); - fStores[i] = stores[i]; + + //If the first store is null, then there must not be any accounts set + //up by the user. + if (stores[0] != null) { + for (int i = 0; i < stores.length; i++) { + fModel.addStore(stores[i]); + fStores[i] = stores[i]; + } } fFolderTree.setDataModel(fModel); @@ -491,9 +496,13 @@ public class MasterPanel extends GeneralPanel { ViewedStore stores[] = StoreFactory.Instance().getStores(); fStores = new ViewedStore[stores.length]; - for (i = 0; i < stores.length; i++) { - fModel.addStore(stores[i]); - fStores[i] = stores[i]; + //If the first store is null, then there must not be any accounts set + //up by the user to add. + if (stores[0] != null) { + for (i = 0; i < stores.length; i++) { + fModel.addStore(stores[i]); + fStores[i] = stores[i]; + } } } } diff --git a/grendel/sources/grendel/ui/StoreFactory.java b/grendel/sources/grendel/ui/StoreFactory.java index dfd94fefd8bd..16eee6c551c9 100644 --- a/grendel/sources/grendel/ui/StoreFactory.java +++ b/grendel/sources/grendel/ui/StoreFactory.java @@ -17,7 +17,7 @@ * Copyright (C) 1997 Netscape Communications Corporation. All * Rights Reserved. * - * Contributor(s): + * Contributor(s): * * Created: Will Scullin , 19 Nov 1997. * @@ -103,7 +103,7 @@ public class StoreFactory { String proto = prefs.getType(); URLName urlName = new URLName(proto,null,-1,null,null,null); - // ### Very wrong temporary hack -- these protocols should be registered + // ### Very wrong temporary hack -- these protocols should be registered // correctly with JavaMail trough the javamail.providers file try { @@ -134,6 +134,8 @@ public class StoreFactory { if (store == null) { try { + if (proto.equals("")) + return null; store = fSession.getStore(proto); } catch (MessagingException e) { System.out.println("Got exception " + e + @@ -146,7 +148,7 @@ public class StoreFactory { return viewedStore; } - + private synchronized void closeStores() { for (int i=0; i