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 7027601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:16:09+00:00 2026-05-28T00:16:09+00:00

I’m building a JCA adapter with a custom ‘connection’ class. In all of the

  • 0

I’m building a JCA adapter with a custom ‘connection’ class. In all of the examples I’ve seen, you’re supposed to put a “void close()” in your connection class. Then while using your custom connection class, you have to put a call to close() in a finally block.

I don’t really trust the developers to remember to put close in a finally block. Also, I don’t have to call “close()” on an EntityManager. The container manages opening and close of the EntityManager automatically.

Is there a way to have the container auto close any connections to my JCA adapter? I’ve tried overriding finalize(), but it could be a very long time before the JVM decides to cleanup my connections.

Or, if someone knew how to write a plugin for findbugs to identity everywhere the custom connection class was used without close() in a finally block… I’d probably be ok with that.

  • 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-05-28T00:16:10+00:00Added an answer on May 28, 2026 at 12:16 am

    If you know your workflow, you could have a background thread watching activity on your connections, and close anything after a certain amount time (10s, 30s, 2 hrs, whatever).

    You could also override the finalize method, as you mentioned. It’s usable, just not guaranteed. But on any reasonably busy server, you will likely be getting enough GC activity to have it close most of your connections in time. The caveat of no guarantee with finalize is simply to accept that if someone kills the process (or it faults or whatever), your finalize won’t be called.

    Finally, it’s straightforward capture where a connection is created by simply creating a new Exception and filling in its stack trace. Keep that exception around with the open connection, and when you detect that you are “forced” to close it (via time, finalize, or whatever), you can simply dump the exception to your log to find the offending “open” line for a connection.

    You should tie in to the JCA lifecycle for when the connector is destroyed, or undeployed (i.e. when the module is removed from the server, or the server shuts down). This can tell you what connections were left open the module was being removed.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I am trying to loop through a bunch of documents I have to put
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.