Bug 734316 - Part 1: Fix some PMD warnings. r=trivial

This commit is contained in:
Richard Newman 2012-03-08 22:43:16 -08:00
parent 770e0d5427
commit 4f0c576b08
10 changed files with 6 additions and 22 deletions

View File

@ -42,7 +42,6 @@ import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map.Entry;
import org.json.JSONException;
import org.json.simple.JSONArray;
import org.json.simple.parser.ParseException;
import org.mozilla.apache.commons.codec.binary.Base64;

View File

@ -51,11 +51,12 @@ public class HTTPFailureException extends SyncException {
@Override
public String toString() {
String errorMessage = "[unknown error message]";
String errorMessage;
try {
errorMessage = this.response.getErrorMessage();
} catch (Exception e) {
// Oh well.
errorMessage = "[unknown error message]";
}
return "<HTTPFailureException " + this.response.getStatusCode() +
" :: (" + errorMessage + ")>";

View File

@ -46,7 +46,6 @@ import javax.crypto.Mac;
import org.mozilla.apache.commons.codec.binary.Base64;
import org.mozilla.gecko.sync.Utils;
import org.mozilla.gecko.sync.crypto.CryptoException;
import java.security.InvalidKeyException;
import java.util.Locale;

View File

@ -54,14 +54,12 @@ public class GetChannelStage extends JPakeStage {
public void handleFailure(String error) {
Logger.error(LOG_TAG, "Got HTTP failure: " + error);
jClient.abort(error);
return;
}
@Override
public void handleError(Exception e) {
Logger.error(LOG_TAG, "Threw HTTP exception.", e);
jClient.abort(Constants.JPAKE_ERROR_CHANNEL);
return;
}
};

View File

@ -75,14 +75,12 @@ public class GetRequestStage extends JPakeStage {
public void handleFailure(String error) {
Logger.error(LOG_TAG, "Got HTTP failure: " + error);
jClient.abort(error);
return;
}
@Override
public void handleError(Exception e) {
Logger.error(LOG_TAG, "Threw HTTP exception.", e);
jClient.abort(Constants.JPAKE_ERROR_NETWORK);
return;
}
};

View File

@ -60,14 +60,12 @@ public class PutRequestStage extends JPakeStage {
public void handleFailure(String error) {
Logger.error(LOG_TAG, "Got HTTP failure: " + error);
jClient.abort(error);
return;
}
@Override
public void handleError(Exception e) {
Logger.error(LOG_TAG, "HTTP exception.", e);
jClient.abort(Constants.JPAKE_ERROR_NETWORK);
return;
}
};

View File

@ -82,6 +82,8 @@ import ch.boye.httpclientandroidlib.protocol.HttpContext;
* Exposes simple get/post/put/delete methods.
*/
public class BaseResource implements Resource {
private static final String ANDROID_LOOPBACK_IP = "10.0.2.2";
public static boolean rewriteLocalhost = true;
private static final String LOG_TAG = "BaseResource";
@ -107,9 +109,9 @@ public class BaseResource implements Resource {
public BaseResource(URI uri, boolean rewrite) {
if (rewrite && uri.getHost().equals("localhost")) {
// Rewrite localhost URIs to refer to the special Android emulator loopback passthrough interface.
Log.d(LOG_TAG, "Rewriting " + uri + " to point to 10.0.2.2.");
Log.d(LOG_TAG, "Rewriting " + uri + " to point to " + ANDROID_LOOPBACK_IP + ".");
try {
this.uri = new URI(uri.getScheme(), uri.getUserInfo(), "10.0.2.2", uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
this.uri = new URI(uri.getScheme(), uri.getUserInfo(), ANDROID_LOOPBACK_IP, uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
} catch (URISyntaxException e) {
Log.e(LOG_TAG, "Got error rewriting URI for Android emulator.", e);
}

View File

@ -12,7 +12,6 @@ import org.mozilla.gecko.sync.ExtendedJSONObject;
import org.mozilla.gecko.sync.Logger;
import org.mozilla.gecko.sync.NonArrayJSONException;
import org.mozilla.gecko.sync.Utils;
import org.mozilla.gecko.sync.repositories.domain.Record;
/**
* Represents a client's collection of tabs.

View File

@ -52,11 +52,6 @@ public class AndroidBrowserBookmarksServerSyncStage extends ServerSyncStage {
private static final String BOOKMARKS_SORT = "index";
private static final long BOOKMARKS_REQUEST_LIMIT = 5000; // Sanity limit.
@Override
public void execute(org.mozilla.gecko.sync.GlobalSession session) throws NoSuchStageException {
super.execute(session);
}
@Override
protected String getCollection() {
return "bookmarks";

View File

@ -52,11 +52,6 @@ public class AndroidBrowserHistoryServerSyncStage extends ServerSyncStage {
private static final String HISTORY_SORT = "index";
private static final long HISTORY_REQUEST_LIMIT = 250;
@Override
public void execute(org.mozilla.gecko.sync.GlobalSession session) throws NoSuchStageException {
super.execute(session);
}
@Override
protected String getCollection() {
return "history";