Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9023945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:53:09+00:00 2026-06-16T05:53:09+00:00

I am receiving the below error message when I execute this code. A resource

  • 0

I am receiving the below error message when I execute this code.

A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.:

I am unable to identify the resource leak in the below code. I’ll be greatful if anyone point out what actually I am doing wrong.

HttpPost request = new HttpPost(url);
        StringBuilder sb = new StringBuilder();
        StringEntity entity = new StringEntity(jsonString);
        entity.setContentType("application/json;charset=UTF-8");
        entity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json;charset=UTF-8"));
        request.setHeader("Accept", "application/json");
        request.setEntity(entity);

        HttpResponse response = null;
        DefaultHttpClient httpclient = getHttpClientImpl();

        BufferedReader reader = null;
        InputStream in = null;
        try {
            response = httpclient.execute(request);
            in = response.getEntity().getContent();
            reader = new BufferedReader(new InputStreamReader(in));
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception se) {
            Log.e("Exception", se + "");
            throw se;
        } finally {
            if (in != null)
                in.close();

            if (reader != null)
                reader.close();

            if (client != null && client.getConnectionManager() != null) {
        client.getConnectionManager().shutdown();
    }
        }
        return sb.toString();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:53:10+00:00Added an answer on June 16, 2026 at 5:53 am

    I don’t really see any issues with that code, but I recommend closing all the idle connections in the pool.

    public abstract void closeIdleConnections (long idletime, TimeUnit tunit)
    

    Furthermore, there are some known issues with the DefaultHttpClient when not entirely configured correctly. I recommend using the AndroidHttpClient as an implementation of the HttpClient interface. Visit following documentation for the explanation:

    http://developer.android.com/reference/android/net/http/AndroidHttpClient.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am receiving below hibernate error message while flush.I am iterating in a for
I am receiving the error Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute , message=Error #3115:
I am receiving the error message below in the command prompt when using the
I've been receiving errors with the following code below saying that the index is
I keep receiving this error... [2012-06-14 11:54:50,072: ERROR/MainProcess] Hard time limit (300s) exceeded for
I am receiving this Uncaught TypeError on a new website I am creating, but
I am receiving a parse error which is this: Parse error: syntax error, unexpected
I'm receiving this error on a page that previously worked fine, in fact the
I'm receiving an error message from the compiler indicating (it's an embedded C compiler):
Could somebody please explain to me why I am receiving the below error, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.