List of usage examples for android.util Log isLoggable
public static native boolean isLoggable(String tag, int level);
From source file:com.cerema.cloud2.lib.common.SingleSessionManager.java
@Override public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException { if (Log.isLoggable(TAG, Log.DEBUG)) { Log_OC.d(TAG, "getClientFor starting "); }/*from w w w . j a va2 s. c o m*/ if (account == null) { throw new IllegalArgumentException("Cannot get an OwnCloudClient for a null account"); } OwnCloudClient client = null; String accountName = account.getName(); String sessionName = account.getCredentials() == null ? "" : AccountUtils.buildAccountName(account.getBaseUri(), account.getCredentials().getAuthToken()); if (accountName != null) { client = mClientsWithKnownUsername.get(accountName); } boolean reusingKnown = false; // just for logs if (client == null) { if (accountName != null) { client = mClientsWithUnknownUsername.remove(sessionName); if (client != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log_OC.v(TAG, "reusing client for session " + sessionName); } mClientsWithKnownUsername.put(accountName, client); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log_OC.v(TAG, "moved client to account " + accountName); } } } else { client = mClientsWithUnknownUsername.get(sessionName); } } else { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log_OC.v(TAG, "reusing client for account " + accountName); } reusingKnown = true; } if (client == null) { // no client to reuse - create a new one client = OwnCloudClientFactory.createOwnCloudClient(account.getBaseUri(), context.getApplicationContext(), true); // TODO remove dependency on OwnCloudClientFactory client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); // enable cookie tracking AccountUtils.restoreCookies(accountName, client, context); account.loadCredentials(context); client.setCredentials(account.getCredentials()); if (accountName != null) { mClientsWithKnownUsername.put(accountName, client); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log_OC.v(TAG, "new client for account " + accountName); } } else { mClientsWithUnknownUsername.put(sessionName, client); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log_OC.v(TAG, "new client for session " + sessionName); } } } else { if (!reusingKnown && Log.isLoggable(TAG, Log.VERBOSE)) { Log_OC.v(TAG, "reusing client for session " + sessionName); } keepCredentialsUpdated(account, client); keepUriUpdated(account, client); } if (Log.isLoggable(TAG, Log.DEBUG)) { Log_OC.d(TAG, "getClientFor finishing "); } return client; }
From source file:com.joptimizer.optimizers.NewtonLEConstrainedFSP.java
@Override public int optimize() throws Exception { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "optimize"); OptimizationResponse response = new OptimizationResponse(); //checking responsibility if (getFi() != null) { // forward to the chain return forwardOptimizationRequest(); }/*from ww w . j ava2 s . c o m*/ long tStart = System.currentTimeMillis(); //initial point must be feasible (i.e., satisfy x in domF and Ax = b). DoubleMatrix1D X0 = getInitialPoint(); double rPriX0Norm = (X0 != null) ? Math.sqrt(ALG.norm2(rPri(X0))) : 0d; //if (X0 == null || (getA()!=null && Double.compare(ALG.norm2(getA().zMult(X0, getB().copy(), 1., -1., false)), 0d) != 0)) { //if (X0 == null || rPriX0Norm > Utils.getDoubleMachineEpsilon()) { if (X0 == null || rPriX0Norm > getTolerance()) { // infeasible starting point, forward to the chain return forwardOptimizationRequest(); } if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X0: " + ArrayUtils.toString(X0.toArray())); } DoubleMatrix1D X = X0; double F0X; //double previousF0X = Double.NaN; double previousLambda = Double.NaN; int iteration = 0; while (true) { iteration++; F0X = getF0(X); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "iteration " + iteration); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X=" + ArrayUtils.toString(X.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "f(X)=" + F0X); } // if(!Double.isNaN(previousF0X)){ // if (previousF0X < F0X) { // throw new Exception("critical minimization problem"); // } // } // previousF0X = F0X; // custom exit condition if (checkCustomExitConditions(X)) { response.setReturnCode(OptimizationResponse.SUCCESS); break; } DoubleMatrix1D gradX = getGradF0(X); DoubleMatrix2D hessX = getHessF0(X); double gradXNorm = Math.sqrt(ALG.norm2(gradX)); if (gradXNorm < Utils.getDoubleMachineEpsilon()) { response.setReturnCode(OptimizationResponse.SUCCESS); break; } // Newton step and decrement if (this.kktSolver == null) { this.kktSolver = new BasicKKTSolver(); } if (isCheckKKTSolutionAccuracy()) { kktSolver.setCheckKKTSolutionAccuracy(isCheckKKTSolutionAccuracy()); kktSolver.setToleranceKKT(getToleranceKKT()); } kktSolver.setHMatrix(hessX.toArray()); kktSolver.setGVector(gradX.toArray()); if (getA() != null) { kktSolver.setAMatrix(getA().toArray()); kktSolver.setATMatrix(getAT().toArray()); } double[][] sol = kktSolver.solve(); DoubleMatrix1D step = F1.make(sol[0]); DoubleMatrix1D w = (sol[1] != null) ? F1.make(sol[1]) : F1.make(0); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "stepX: " + ArrayUtils.toString(step.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "w : " + ArrayUtils.toString(w.toArray())); } // exit condition: check the Newton decrement double lambda = Math.sqrt(ALG.mult(step, ALG.mult(hessX, step))); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "lambda: " + lambda); if (lambda / 2. <= getTolerance()) { response.setReturnCode(OptimizationResponse.SUCCESS); break; } // iteration limit condition if (iteration == getMaxIteration()) { response.setReturnCode(OptimizationResponse.WARN); Log.w(MainActivity.JOPTIMIZER_LOGTAG, "Max iterations limit reached"); break; } // progress conditions if (isCheckProgressConditions()) { if (!Double.isNaN(previousLambda) && previousLambda <= lambda) { Log.w(MainActivity.JOPTIMIZER_LOGTAG, "No progress achieved, exit iterations loop without desired accuracy"); response.setReturnCode(OptimizationResponse.WARN); break; } } previousLambda = lambda; // backtracking line search double s = 1d; DoubleMatrix1D X1 = null; int cnt = 0; while (cnt < 250) { cnt++; // @TODO: can we use simplification 9.7.1 ?? X1 = X.copy().assign(step.copy().assign(Mult.mult(s)), Functions.plus);// x + t*step //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"X1: "+ArrayUtils.toString(X1.toArray())); if (isInDomainF0(X1)) { double condSX = getF0(X1); //NB: this will also check !Double.isNaN(getF0(X1)) double condDX = F0X + getAlpha() * s * ALG.mult(gradX, step); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"condSX: "+condSX); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"condDX: "+condDX); if (condSX <= condDX) { break; } } s = getBeta() * s; } Log.d(MainActivity.JOPTIMIZER_LOGTAG, "s: " + s); // update X = X1; } long tStop = System.currentTimeMillis(); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "time: " + (tStop - tStart)); response.setSolution(X.toArray()); setOptimizationResponse(response); return response.getReturnCode(); }
From source file:com.example.android.wearable.timer.TimerNotificationService.java
private void deleteTimer() { cancelCountdownNotification();//www . ja v a 2 s . co m AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(Constants.ACTION_SHOW_ALARM, null, this, TimerNotificationService.class); PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); alarm.cancel(pendingIntent); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Timer deleted."); } }
From source file:com.goliathonline.android.kegbot.io.RemoteTapHandler.java
/** {@inheritDoc} */ @Override/*from ww w . j av a 2 s . c o m*/ public ArrayList<ContentProviderOperation> parse(JSONObject parser, ContentResolver resolver) throws JSONException, IOException { final ArrayList<ContentProviderOperation> batch = Lists.newArrayList(); if (parser.has("result")) { JSONObject events = parser.getJSONObject("result"); JSONArray resultArray = events.getJSONArray("taps"); int numKegs = resultArray.length(); JSONObject taps; for (int i = 0; i < numKegs; i++) { taps = resultArray.getJSONObject(i); JSONObject keg = taps.getJSONObject("keg"); JSONObject tap = taps.getJSONObject("tap"); JSONObject beer = taps.getJSONObject("beer_type"); JSONObject image = beer.getJSONObject("image"); final String tapId = sanitizeId(tap.getString("id")); final Uri tapUri = Taps.buildTapUri(tapId); // Check for existing details, only update when changed final ContentValues values = queryTapDetails(tapUri, resolver); final long localUpdated = values.getAsLong(SyncColumns.UPDATED); final long serverUpdated = 500; //entry.getUpdated(); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "found tap " + tapId); Log.v(TAG, "found localUpdated=" + localUpdated + ", server=" + serverUpdated); } // Clear any existing values for this session, treating the // incoming details as authoritative. batch.add(ContentProviderOperation.newDelete(tapUri).build()); final ContentProviderOperation.Builder builder = ContentProviderOperation .newInsert(Taps.CONTENT_URI); builder.withValue(SyncColumns.UPDATED, serverUpdated); builder.withValue(Taps.TAP_ID, tapId); if (tap.has("name")) builder.withValue(Taps.TAP_NAME, tap.getString("name")); if (tap.has("current_keg_id")) builder.withValue(Taps.KEG_ID, tap.getDouble("current_keg_id")); if (keg.has("status")) builder.withValue(Taps.STATUS, keg.getString("status")); if (keg.has("percent_full")) builder.withValue(Taps.PERCENT_FULL, keg.getString("percent_full")); if (keg.has("size_name")) builder.withValue(Taps.SIZE_NAME, keg.getString("size_name")); if (keg.has("volume_ml_remain")) builder.withValue(Taps.VOL_REMAIN, keg.getDouble("volume_ml_remain")); if (keg.has("size_volume_ml")) builder.withValue(Taps.VOL_SIZE, keg.getDouble("size_volume_ml")); if (beer.has("name")) builder.withValue(Taps.BEER_NAME, beer.getString("name")); if (keg.has("description")) builder.withValue(Taps.DESCRIPTION, keg.getString("description")); JSONObject last_temp = tap.getJSONObject("last_temperature"); if (last_temp.has("temperature_c")) builder.withValue(Taps.LAST_TEMP, last_temp.getString("temperature_c")); if (last_temp.has("record_time")) builder.withValue(Taps.LAST_TEMP_TIME, last_temp.getString("record_time")); if (image.has("url")) builder.withValue(Taps.IMAGE_URL, image.getString("url")); // Normal tap details ready, write to provider batch.add(builder.build()); } } return batch; }
From source file:com.sleekcoder.weardemo.DismissListener.java
private void dismissWearableNotification(final int id) { mGoogleApiClient.connect();//from www.jav a 2s .com final Uri dataItemUri = new Uri.Builder().scheme(WEAR_URI_SCHEME).path(Constants.BOTH_PATH).build(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Deleting Uri: " + dataItemUri.toString()); } Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItemUri).setResultCallback(this); }
From source file:com.wearclan.mechanicalwatchface.DataLayerListenerService.java
public static void LOGD(final String tag, String message) { if (Log.isLoggable(tag, Log.DEBUG)) { Log.d(tag, message);/* w w w . j a v a 2s. c o m*/ } }
From source file:com.example.android.elizachat.ResponderService.java
private void showNotification() { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Sent: " + mLastResponse); }/*from w w w .j a va 2 s . co m*/ NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setContentTitle(getString(R.string.eliza)).setContentText(mLastResponse) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.bg_eliza)) .setSmallIcon(R.drawable.bg_eliza).setPriority(NotificationCompat.PRIORITY_MIN); Intent intent = new Intent(ACTION_RESPONSE); PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT); Notification notification = builder.extend(new NotificationCompat.WearableExtender() .addAction(new NotificationCompat.Action.Builder(R.drawable.ic_full_reply, getString(R.string.reply), pendingIntent).addRemoteInput( new RemoteInput.Builder(EXTRA_REPLY).setLabel(getString(R.string.reply)).build()) .build())) .build(); NotificationManagerCompat.from(this).notify(0, notification); }
From source file:com.example.android.wearable.elizachat.ResponderService.java
private void showNotification() { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Sent: " + mLastResponse); }//from ww w. j a va2s . c o m NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setContentTitle(getString(R.string.eliza)).setContentText(mLastResponse) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.bg_eliza)) .setSmallIcon(R.drawable.bg_eliza).setPriority(NotificationCompat.PRIORITY_DEFAULT); Intent intent = new Intent(ACTION_RESPONSE); PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT); Notification notification = builder.extend(new NotificationCompat.WearableExtender() .addAction(new NotificationCompat.Action.Builder(R.drawable.ic_full_reply, getString(R.string.reply), pendingIntent).addRemoteInput( new RemoteInput.Builder(EXTRA_REPLY).setLabel(getString(R.string.reply)).build()) .build())) .build(); NotificationManagerCompat.from(this).notify(0, notification); }
From source file:com.android.ex.chips.RecipientAlternatesAdapter.java
/** * Get a HashMap of address to RecipientEntry that contains all contact * information for a contact with the provided address, if one exists. This * may block the UI, so run it in an async task. * @param context//w ww . j ava 2 s .c o m * Context. * @param inAddresses * Array of addresses on which to perform the lookup. * @return HashMap<String,RecipientEntry> */ public static HashMap<String, RecipientEntry> getMatchingRecipients(Context context, ArrayList<String> inAddresses, int addressType) { Queries.Query query; if (addressType == QUERY_TYPE_EMAIL) { query = Queries.EMAIL; } else { query = Queries.PHONE; } int addressesSize = Math.min(MAX_LOOKUPS, inAddresses.size()); String[] addresses = new String[addressesSize]; StringBuilder bindString = new StringBuilder(); // Create the "?" string and set up arguments. for (int i = 0; i < addressesSize; i++) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(inAddresses.get(i).toLowerCase()); addresses[i] = (tokens.length > 0 ? tokens[0].getAddress() : inAddresses.get(i)); bindString.append("?"); if (i < addressesSize - 1) { bindString.append(","); } } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Doing reverse lookup for " + addresses.toString()); } HashMap<String, RecipientEntry> recipientEntries = new HashMap<String, RecipientEntry>(); Cursor c = context.getContentResolver().query(query.getContentUri(), query.getProjection(), query.getProjection()[Queries.Query.DESTINATION] + " IN (" + bindString.toString() + ")", addresses, null); if (c != null) { try { if (c.moveToFirst()) { do { String address = c.getString(Queries.Query.DESTINATION); recipientEntries.put(address, RecipientEntry.constructTopLevelEntry( c.getString(Queries.Query.NAME), c.getInt(Queries.Query.DISPLAY_NAME_SOURCE), c.getString(Queries.Query.DESTINATION), c.getInt(Queries.Query.DESTINATION_TYPE), c.getString(Queries.Query.DESTINATION_LABEL), c.getLong(Queries.Query.CONTACT_ID), c.getLong(Queries.Query.DATA_ID), c.getString(Queries.Query.PHOTO_THUMBNAIL_URI))); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Received reverse look up information for " + address + " RESULTS: " + " NAME : " + c.getString(Queries.Query.NAME) + " CONTACT ID : " + c.getLong(Queries.Query.CONTACT_ID) + " ADDRESS :" + c.getString(Queries.Query.DESTINATION)); } } while (c.moveToNext()); } } finally { c.close(); } } return recipientEntries; }
From source file:com.geocine.mms.com.android.mms.transaction.HttpUtils.java
/** * A helper method to send or retrieve data through HTTP protocol. * * @param token The token to identify the sending progress. * @param url The URL used in a GET request. Null when the method is * HTTP_POST_METHOD./*from w w w .ja va2s . com*/ * @param pdu The data to be POST. Null when the method is HTTP_GET_METHOD. * @param method HTTP_POST_METHOD or HTTP_GET_METHOD. * @return A byte array which contains the response data. * If an HTTP error code is returned, an IOException will be thrown. * @throws IOException if any error occurred on network interface or * an HTTP error code(>=400) returned from the server. */ protected static byte[] httpConnection(Context context, long token, String url, byte[] pdu, int method, boolean isProxySet, String proxyHost, int proxyPort) throws IOException { if (url == null) { throw new IllegalArgumentException("URL must not be null."); } if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) { Log.v(TAG, "httpConnection: params list"); Log.v(TAG, "\ttoken\t\t= " + token); Log.v(TAG, "\turl\t\t= " + url); Log.v(TAG, "\tmethod\t\t= " + ((method == HTTP_POST_METHOD) ? "POST" : ((method == HTTP_GET_METHOD) ? "GET" : "UNKNOWN"))); Log.v(TAG, "\tisProxySet\t= " + isProxySet); Log.v(TAG, "\tproxyHost\t= " + proxyHost); Log.v(TAG, "\tproxyPort\t= " + proxyPort); // TODO Print out binary data more readable. //Log.v(TAG, "\tpdu\t\t= " + Arrays.toString(pdu)); } AndroidHttpClient client = null; try { // Make sure to use a proxy which supports CONNECT. URI hostUrl = new URI(url); HttpHost target = new HttpHost(hostUrl.getHost(), hostUrl.getPort(), HttpHost.DEFAULT_SCHEME_NAME); client = createHttpClient(context); HttpRequest req = null; switch (method) { case HTTP_POST_METHOD: ProgressCallbackEntity entity = new ProgressCallbackEntity(context, token, pdu); // Set request content type. entity.setContentType("application/vnd.wap.mms-message"); HttpPost post = new HttpPost(url); post.setEntity(entity); req = post; break; case HTTP_GET_METHOD: req = new HttpGet(url); break; default: Log.e(TAG, "Unknown HTTP method: " + method + ". Must be one of POST[" + HTTP_POST_METHOD + "] or GET[" + HTTP_GET_METHOD + "]."); return null; } // Set route parameters for the request. HttpParams params = client.getParams(); if (isProxySet) { ConnRouteParams.setDefaultProxy(params, new HttpHost(proxyHost, proxyPort)); } req.setParams(params); // Set necessary HTTP headers for MMS transmission. req.addHeader(HDR_KEY_ACCEPT, HDR_VALUE_ACCEPT); { String xWapProfileTagName = MmsConfig.getUaProfTagName(); String xWapProfileUrl = MmsConfig.getUaProfUrl(); if (xWapProfileUrl != null) { if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) { Log.d(LogTag.TRANSACTION, "[HttpUtils] httpConn: xWapProfUrl=" + xWapProfileUrl); } req.addHeader(xWapProfileTagName, xWapProfileUrl); } } // Extra http parameters. Split by '|' to get a list of value pairs. // Separate each pair by the first occurrence of ':' to obtain a name and // value. Replace the occurrence of the string returned by // MmsConfig.getHttpParamsLine1Key() with the users telephone number inside // the value. String extraHttpParams = MmsConfig.getHttpParams(); if (extraHttpParams != null) { String line1Number = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)) .getLine1Number(); String line1Key = MmsConfig.getHttpParamsLine1Key(); String paramList[] = extraHttpParams.split("\\|"); for (String paramPair : paramList) { String splitPair[] = paramPair.split(":", 2); if (splitPair.length == 2) { String name = splitPair[0].trim(); String value = splitPair[1].trim(); if (line1Key != null) { value = value.replace(line1Key, line1Number); } if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(value)) { req.addHeader(name, value); } } } } req.addHeader(HDR_KEY_ACCEPT_LANGUAGE, HDR_VALUE_ACCEPT_LANGUAGE); HttpResponse response = client.execute(target, req); StatusLine status = response.getStatusLine(); if (status.getStatusCode() != 200) { // HTTP 200 is success. throw new IOException("HTTP error: " + status.getReasonPhrase()); } HttpEntity entity = response.getEntity(); byte[] body = null; if (entity != null) { try { if (entity.getContentLength() > 0) { body = new byte[(int) entity.getContentLength()]; DataInputStream dis = new DataInputStream(entity.getContent()); try { dis.readFully(body); } finally { try { dis.close(); } catch (IOException e) { Log.e(TAG, "Error closing input stream: " + e.getMessage()); } } } if (entity.isChunked()) { Log.v(TAG, "httpConnection: transfer encoding is chunked"); int bytesTobeRead = MmsConfig.getMaxMessageSize(); byte[] tempBody = new byte[bytesTobeRead]; DataInputStream dis = new DataInputStream(entity.getContent()); try { int bytesRead = 0; int offset = 0; boolean readError = false; do { try { bytesRead = dis.read(tempBody, offset, bytesTobeRead); } catch (IOException e) { readError = true; Log.e(TAG, "httpConnection: error reading input stream" + e.getMessage()); break; } if (bytesRead > 0) { bytesTobeRead -= bytesRead; offset += bytesRead; } } while (bytesRead >= 0 && bytesTobeRead > 0); if (bytesRead == -1 && offset > 0 && !readError) { // offset is same as total number of bytes read // bytesRead will be -1 if the data was read till the eof body = new byte[offset]; System.arraycopy(tempBody, 0, body, 0, offset); Log.v(TAG, "httpConnection: Chunked response length [" + Integer.toString(offset) + "]"); } else { Log.e(TAG, "httpConnection: Response entity too large or empty"); } } finally { try { dis.close(); } catch (IOException e) { Log.e(TAG, "Error closing input stream: " + e.getMessage()); } } } } finally { if (entity != null) { entity.consumeContent(); } } } return body; } catch (URISyntaxException e) { handleHttpConnectionException(e, url); } catch (IllegalStateException e) { handleHttpConnectionException(e, url); } catch (IllegalArgumentException e) { handleHttpConnectionException(e, url); } catch (SocketException e) { handleHttpConnectionException(e, url); } catch (Exception e) { handleHttpConnectionException(e, url); } finally { if (client != null) { client.close(); } } return null; }