Fixing two potential NPEs found by findbugs

This commit is contained in:
kytv
2013-01-01 00:02:18 +00:00
parent adfc22499c
commit c05cd07ff7
2 changed files with 10 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package net.i2p.router.update;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.IllegalArgumentException;
import java.net.URI; import java.net.URI;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -37,6 +38,8 @@ import net.i2p.util.VersionComparator;
* then fetch the first 56 bytes of the URL, extract the version, * then fetch the first 56 bytes of the URL, extract the version,
* and compare. * and compare.
* *
* uri list must not be empty.
*
* Moved from web/ and turned into an UpdateTask. * Moved from web/ and turned into an UpdateTask.
* *
* @since 0.9.4 moved from PluginUpdateHandler * @since 0.9.4 moved from PluginUpdateHandler
@@ -55,10 +58,10 @@ class PluginUpdateRunner extends UpdateRunner {
public static final String PLUGIN_DIR = PluginStarter.PLUGIN_DIR; public static final String PLUGIN_DIR = PluginStarter.PLUGIN_DIR;
public PluginUpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, List<URI> uris, public PluginUpdateRunner(RouterContext ctx, ConsoleUpdateManager mgr, List<URI> uris,
String appName, String oldVersion ) { String appName, String oldVersion ) {
super(ctx, mgr, uris); super(ctx, mgr, uris);
if (uris.isEmpty()) if (uris.isEmpty())
_uri = null; throw new IllegalArgumentException("uri cannot be empty");
else else
_uri = uris.get(0); _uri = uris.get(0);
_xpi2pURL = _uri.toString(); _xpi2pURL = _uri.toString();

View File

@@ -184,12 +184,14 @@ public class ProfileOrganizer {
* *
*/ */
public PeerProfile addProfile(PeerProfile profile) { public PeerProfile addProfile(PeerProfile profile) {
if (profile == null) return null;
Hash peer = profile.getPeer(); Hash peer = profile.getPeer();
if (profile == null || peer == null) return null; if (peer == null) return null;
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("New profile created for " + peer); _log.debug("New profile created for " + peer);
PeerProfile old = getProfile(peer); PeerProfile old = getProfile(peer);
profile.coalesceStats(); profile.coalesceStats();
if (!getWriteLock()) if (!getWriteLock())