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

  • SEARCH
  • Home
  • 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 8950633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:29:20+00:00 2026-06-15T13:29:20+00:00

I made some tests (using Windows 7, Eclipse Juno 4.2.1 and Java 7 SE)

  • 0

I made some tests (using Windows 7, Eclipse Juno 4.2.1 and Java 7 SE) and found that if a method did not explicitly return in the catch-block and if the object was declared outside the try/catch, then no “resource leak” warning was signaled.

Does not generate “resource leak”:

    public void extISImReturnNoWarning() {
    InputStream is = null;
    try {
        is = new FileInputStream("A");
        is.available();
    } catch (IOException e) {
    }
}

Small changes in the code generate “resource leaks”:

public void locISImReturnHasWarning() {
    try {
        InputStream is = new FileInputStream("A");
        is.available();
    } catch (IOException e) {
    }
}

public void extISExReturnHasWarning() {
    InputStream is = null;
    try {
        is = new FileInputStream("A");
        is.available();
    } catch (IOException e) {
        return;
    }
}

All methods seems functionally identical – so what can the explanation be? If this is a bug, is this an Eclipse or Java issue?

  • 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-15T13:29:21+00:00Added an answer on June 15, 2026 at 1:29 pm

    After some research, I’ve come to the conclusion that this is an Eclipse bug. I’ve tested it in the latest build I’ve found on Eclipse Download site (Kepler M3), but the issue persists. I’ve also found 5-6 bug reports on similar issues reported the last 30 days in the Eclipse project. During the research I also found another peculiar behavior:

        public void makeConnection() throws SQLException {
        Connection connection = null;
        try {
            connection = DriverManager.getConnection("localhost");
            for (int i = 0; i < 1; i++)
                if (i < 1)
                    throw new SQLException("Foo");
            connection.commit();
        } finally {
            close(connection);
        }
    }
    
    public void close(Connection c) {
    }
    

    This code will generate a resource leak warning. However, by removing one of these

    • the call to close(connection)
    • the for-loop

    ..the resource leak warning will disappear. Strangely enough – no resource leak will be reported in a vanilla case, where you simply create a connection and do not close it.

    All in all, I think the resource leak detection in Eclipse Juno might be a little bug-prone for the time being. Maybe it’s for the best to ignore resource leaks in Eclipse right now, and wait for Kepler.

    Update dec 2014 : Currently running Eclipse Luna, and the issue persists…

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

Sidebar

Related Questions

I have a class that I made for some unit tests. Everything was going
I made test application in Delphi that beeps morse code using Windows API Beep
I made some Eclipse plugin and update site on Indigo(Eclipse v3.7). I can debug
After I made some researches, I found out there is only one way to
Apparently, Windows made some major changes to the audio architecture in Windows Vista. As
I programmed a simple html page with some buttons on them that I made
I've made a website, to test the html5 audio. Unfortunately some browser doesn't support
I made some little programs with Swing-components in JRuby. Now I want to convert
I made some modifications to SVG Edit which contains a make file. When I
I made some code to produce boxes every time my code encounters a white

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.