The Age of Magoo
It‘s official, the whole world is obsessed with Dunning/Kruger; Dr. Mercola was blogging about it this morning. He apparently read Errol Morris‘ piece in the NYT. Going back to the source, the two were pondering the case of the bank robber who was so dumb he didn‘t have the capacity to grasp his own incapacity. I‘ve already blogged about D-K. I was obsessed with it when I first found it using “StumbleUpon” because I‘ve seen it a thousand times in IT: people who you ask ‘give yourself a score on Design Patterns 1 to 10‘ and they say ‘9‘ and then you say ‘give me an example of Composite‘ and they say ‘when one thing is made up of other things?‘
Today, I was going to blog about fixing 2 bugs this week that were ultimately, it turned out, strangely related (in totally different projects). One involved a computation of infinity and the other the infinitesimal, which got me thinking about one of my favorite films of all time: The Incredible Shrinking Man I did a tour in college running the film series one year which was thankless since people in, yes, the birthplace of film, were not disinterested, they were belligerently opposed to foreign film or anything more ambitious than The Blues Brothers When I showed this film, it was a really interesting divining rod: the intellectuals who'd been turning out for the likes of Bergman and Bresson were totally put off, and a lot of the witless action/thrill-seekers were turned off by the pretensions. There's a reason this film has a 7.7 on imdb, and garners a mention in serious film analysis books like Amos Vogel's great Film as a Subversive Art
I hated the show “Mr. Magoo” when I was a kid, but I find myself bringing it up all the time these days. Today, I realized that Magoo and TISM are kind of opposite ends of the Dunning-Kruger spectrum: Magoo is man hurtling into the accelerating freneticism of the future completely oblivious (like the D-K bank robber thinking he‘s invisible) while TISM is Russell‘s too conscious man, literally seeing himself shrinking away from a world that is becoming more and more dominated by things. All great works of art have some level of allegory, and TISM is one of the great ones of all time (thanks to Richard Matheson‘s amazing script and great direction). What a prescient vision from the end of the 50s: as humankind shrivels, the struggle to hold onto some dignity is the natural first phase, but it quickly gives way to a desperate struggle to not perish at the hands of objects over which assured mastery it seems was merely a function of scale. The still is one of my favorites from film history: rousted from his doll house digs, the protagonist ends up in the doorway to the underworld (his basement), with an animal that is a miniaturized version of one of the most lethal organisms the ecosystem has ever produced, clearly, there is no way the last defense will hold. But the film‘s not done there: the last chance is that the wife, whose intuition is that her husband is in the basement, might find him. A few more random events conspire to assure this too evaporates, and as his world recedes, we‘re given a few telling signs that his own brother is already moving in on his desperate wife.
Is there anything between these two extremes? In programming, we are constantly being overwhelmed by complexity: soaked in it, and yet, the huge successes of the last few years are treatises in Magoo-like simplicity: Twitter and Facebook. Happened to catch a nauseating trailer for Andrew Sorkin‘s new film about the rise of Facebook. It seriously looks like it‘s going to make Jersey Shore look like Shakespeare in the Park. The lowest, stupidest flagellation, nay moth-like fluttering around the flame of power. Not real power, just its phantom: the temporary slags who got their name in the directory (momentarily). In this week‘s premiere of Mad Men Betty‘s new husband defends her hanging onto the house saying ‘it‘s temporary‘ to which Draper responds ‘everyone knows this is definiitely temporary.‘ Just as the Republicans were making plans for a 25 year lock on power in 2004, and now are looking like the only place they could win a majority is in a population that has a lead-soaked well or the deadly combination of blinding stupidity (D-K) and rash-like paranoia, so goes the saw. (Not a D defender either, they are feeding from a different part of the same pond; anyone vaguely conscious these days is completely fed up with the parties.) More speculation surfaced this week that Facebook could be another MySpace, while the latter, it turns out, is trying to rebrand itself younger (tyke trolling).
Anyway, my point is: maybe we have reached that stage where things are popping so quickly, there is such a scramble to grasp that the dignified fight is the 300: hopeless, but better than captivity, and thus the future holds only a revolving door of magoos. It has steeled my conviction that what we need most on the complexity side are two things: a firm embrace of it, that includes walking away from the rigid stupidity of the scientific method in favor of a world view dominated by probability (more on this), and tools to help us absorb our world more efficiently. In the past week or two, after converting to Git, using GitX to view commit sets, and watching the xcode 4 preview has made me realize that despite a decade just ended that was dominated by tools, clearly we forget that if each time we use them, we come out the other side not knowing anything new (I would argue this is the norm), then they are but a turnstile and we but their ear-tagged chattel.
Eclipse 4.0 Application Platform – Tutorial Updated
As you know the Eclipse 4.0 SDK is out.
It also appears in discussions that some people don’t think Eclipse e4 is a good idea.
Other people seem to like it.
To help you to decide yourself I updated my Eclipse e4 Tutorial to Eclipse 4.0 Application Platform – Tutorial.
Together with Tom Schindls Tutorial you should be able to have a good start with Eclipse 4.0 SDK.
Please remember that the target of the core e4 Project is to improve the programming model of Eclipse and to provide an improved way of influencing the UI. The standard plugins are still the same and behave the same way.
My Tutorial also needs improvements, unfortunately it is not as far and deep as I like, but I hope that is will give you a good start. If you find issues, problems with my tutorial please let me know. The “more to come” section of my tutorial lists my future plans.
Java Performance News June 2010
June 2010 New Java Performance Tips
Cartoon by profiler: Synchronize to avoid race conditions
Cartoon by profiler: Use collections correctly
June 2010 Javva The Hutt
Griffon: new release means new plugins too
Layouts As Geertjan prophesied in MigLayout: Inevitable Choice for Griffon Users?, MigLayout is now available as a plugin. But it's not alone, there are other layout alternatives in the form of DesignGridLayout, RiverLayout and ZoneLayout.
Look & Feel Java Swing applications have always been attacked as not looking native enough (or even good enough). No problem, just install the LookAndFeel plugin and you get a configurable way to change the Look & Feel, even after the UI has been displayed. Many Swing developers will agree that the most versatile and elegant L&F theme collection is found in the Substance project, you'll be happy to know that Substance is available as a pluggable L&F provider, along with A03, EaSynth, JGoodies Looks, JTattoo, Kunststoff, Liquid, Metouia, Napkin, NimROD, OfficeLnfs, Pagosoft, Skin, Squareness, Tinylaf and Tonic.
Effects and Glitz Closely related to the L&F topic are effects and additional glitz; basically stuff that makes your apps look better while improving the user experience. There's a new group of plugins that provide well know icon sets, like Everaldo's Crystal, Tango! and Mark James' Silk collection. They are joined by Nuvola, Feeds and Countries (also from Mark James' famfamfam flag icons).
The Effects plugin brings you script.aculo.us inspired effects, and while the current number of effects is less than the original you can expect more to be added at a later stage. Charting is now easier thanks to the Charts plugin, which bundles Groovychart, a Groovy builder for JFreeChart. Making graph visualizations is also simple with the JGraph plugin. Lastly, the JXLayer plugin paves the way for compatibility with the upcoming JLayer from JDK7.
Testing You'll find a totally revamped testing infrastructure as one of the biggest changes in Griffon 0.9's buildtime package. This change allows for a new kind of plugins to be built, perhaps the most awaited one is the Spock plugin as it opens the door for a wide range of options. This plugin is a direct port of it's Grails counterpart. Clover is another port from Grails, also marking the first release of a Griffon plugin from a commercial offering.
Persistence On the persistence front we find two new plugins focused on NoSQL: Riak and Memcached. The latter comes with the 3 most popular java clients for connecting to memcached/membase servers, giving you the option to pick and choose the one you like best.
General Finally we also get the Maven Publisher plugin (another port from Grails). This plugin helps in publishing/deploying plugins and applications to Maven repositories, a perfect companion to Griffon's new Dependency DSL mechanism (also borrowed from Grails).
All in all 36 new releases, not bad
Most of the already existing plugins have had releases too, upgrading themselves to Griffon 0.9 and adding a few features. And there are more new plugins coming in the future: 3D support, NoSQL, domain classes, scaffolding, etc.Keep on Groovying!
Maven is good, but needs some love
You know that I've moved to Maven more than one year ago and I don't regret. I think I would be unable to manage the number of projects I'm managing on my own without it (or at least without an effective artifact repository).
But Maven needs a proper and clean environment. Maven experts are constantly advising about that. One of the most important pieces of the environment is the artifact repository. You can create a cheap one with a plain webdav resource, or you can install a specific tool such as Nexus or Artifactory. A plain webdav resource is simpler to manage and might sound as a good solution for simpler cases, while a specific tool is more powerful but more complex to setup and administer. It's your choice: the important thing is that everything is under your control and properly managed.
Hear what's happening to me since a couple of days. Before going on, I'll recap a couple of Maven concepts. When you have a multi-repository project (unfortunately it frequently happens, as some libraries you might depend have their own repo), Maven searches for artifacts in all of them - what typically happens is that the first repo responds with an HTTP 404 - Not Found and Maven searches on until it finds what it needs. Then it stores a metadata XML file to recall where it has last found the artifact. In this way it can avoid constantly polling for things and it's faster.
Now, I have still a few remaining messy things in my projects. When I made the switch one year ago, I thought that a webdav repo was ok for my stuff and used the webdav facility at Kenai. Later I realized that Nexus was worth while, and in any case I was able to deploy most of my stuff to the free Sonatype Maven hosting. But I have still three projects relying on Kenai's webdav. I planned for moving them sooner or later, but I didn't so far because I didn't touch them for some months.
Now, a couple of days ago, Kenai started randomly responding with a small text page saying HTTP 500 - Internal Server Error instead of the HTTP 404 when you ask for a non-existing resource - but the status code is set to 200 so Maven and Nexus, that clearly aren't much smart sometimes, instead of treating this as a "not found", are accepting the resource that is served with the error. The resource, of course, is a small HTML page with the text "Internal Server Error" etc... Of course, storing this as an artifact, a POM, or a metadata XML file isn't good at all and breaks the build. In a couple of days, the error literally poisoned all my repositories, both Nexus and the one on my disk, and all my builds are broken. Now I'm compelled to fix the thing ASAP - and I'm forced to postpone my next release of blueBill, since this week will be focused on the required clean up.
Clearly, it's not entirely a Maven fault (even though that silly way of handling HTTP 500 is crying out loud); the problem originated from Kenai and a messy situation in my software factory. With Maven, you must be very precise and accurate. You can take this as an annoyance - on the other hand it's also a stimulus for setting up things properly.
I do hope that the next release of the Maven tools, anyway, will have this sort of silly bugs fixed.
Speak like a native – How to use native code (Windows DLL) in OSGi
As you know the OSGi Framework enforces strong modularity. This also applies to native library code, e.g. a Windows DLL.
To make your DLL available in the context of OSGi you have to use the Bundle-NativeCode section in MANIFEST.MF.
For example if your DLL is called “sapjco3.dll” and is in the main path of you bundle you can use.
Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Jco Bundle-SymbolicName: com.sap.conn.jco Bundle-Version: 1.0.0 Bundle-ClassPath: sapjco3.jar Bundle-NativeCode: /sapjco3.dll; osname=win32; processor=x86 Export-Package: com.sap.conn.jco,
Many thanks to Matthias Heinrich for the tip.
Come learn to kick-butt in Java Build Automation, Automated Testing, Code Quality, CI and more!
Maven 3, Selenium 2/WebDriver, easyb, Hudson, and more! The next sessions of the Java Power Tools Bootcamps are coming up soon in Wellington, London, and Canberra. Don't miss out on this great opportunity to learn some very useful and very cool skills and best practices in the areas of build automation, code quality, automated testing and continuous integration.
This is always a popular course, and once again all of the modules have been extensively updated with new material. Some of the highlights of this season include:
- Advanced Maven build automation, including automated releases, automated deployments, Nexus, and Maven 3
- Code quality best practices: Checkstyle, PMD, FindBugs, Cobertura, Sonar, and how to make them work for your teams
- JUnit Kung Fu, parameterized tests, theories, custom Hamcrest asserts, Custom JUnit test runners,
- Automated web testing with Selenium 2/WebDriver, and Behavior-Driven Development/Acceptance Test Driven Development with easyb
- Advanced Continuous Integration with Hudson, including automated code quality and code coverage metrics, parameterized build jobs, build promotion, automated deployment and distributed builds.
The session dates are:
- Wellington: August 30-September 3
- London: September 13-17
- Canberra: October 18-22
Places are limited, so what are you waiting for? Sign up now!
Adding Hardware is not Always the Cheapest Option
New Refrigerant 99% Less Noxious
Wow, this is super cool. Where is the version for home units, though? They got a new one in the last decade called R410, but it‘s probably not this green. Maybe this can be used in home units too, but GM is just stepping up to add it to their cars first.
Air conditioning also sucks a LOT of electricity when it runs. Unless you live in a place that has a huge flat roof over a dug in bunker, you cannot offset air conditioning with solar. My own solar panels have generated only about $40 less electricity than I have used in the last 10 months, but when the A/C is running, the meter explodes (my unit is 10 SEER, some of the newer ones are as high as 20, but you can‘t justify the cost difference unless you run them all the time).
These types of innovations would maybe be better served by a prize rather than product-based economy: put out a $10M prize for a new refrigerant or an air conditioner that can do 30 SEER or a solar panel that can attain 30% efficiency. Then the technology adoption could be universal.
Infoworld: Google's Waterloo Too, Apparently
In the same way that Mama Mia didn‘t affect Meryl Streep‘s status as the most respected actress in the world, the idiotic prognostications of press members just come and go like a tax-payer funded wall street bonus. If the weatherman kept saying rain, I‘m thinking (s)he would get removed at some point, but maybe not..
Yo, Guys, looks like DroidX has the death grip (mortgage) problem too.
See it here .
At least the people over at BusinessWeek zeroed in on the fact that this is a rampant condition, not the finally hoped for Apple achilles heel. (Notice the similarities to the Sherrod story: people looking and only seeing what they wanted to see, to reinforce their own stupid fears?)
Xcode 4: The IDE Apocalypse
I downloaded the WWDC sessions and was watching one of them this morning. It was about using the existing version of Xcode. The meat of it was a recipe application for the phone being turned into an iPad app. Probably the most important thing that determines the success of presentations like these is the degree to which they communicate flow state. This presentation (WWDC Session 305) succeeds to a pretty astounding degree. Of course, part of the reason is that it‘s polished and the presenter is rehearsed, but you start to pretty quickly realize that you have popped through to a level of that is a direct reflection on the product. Showing, not just a piece or some preconstrained view of something, but a whole, in the commission of some externally defined value exchange, is not the usual stock and trade of conferences. As a matter of fact, during this session, I of course, started to think ‘what would the Java version of this look like?‘ My answer was, it would make Andy Warhol‘s 8 hour epic Sleep look like a 15s Animaniacs interstitial.
We are into a new decade. The last one was dominated by tools. Many of us believed that tools would suture the many disparate parts and pieces of the Java world. In retrospect, it seems kind of silly. Flow state does not just spontaneously appear through some kind of Tinkerbelle-induced incantation. If Lean is about anything it's about minding the VSM. It isn‘t so much that the Java world is mindless, it‘s more that in the name of ‘choice,‘ it‘s left to each person to construct their own VSM, with only fragmented help from each framework and no one to vouch for the combination.

Of course, I thought about doing the 4th grade class report format of comparing and contrasting Xcode to eclipse. There are still quite a few things that Xcode does not do that eclipse does, for instance, I have a lot of templates setup in eclipse, that allow me to define variables. Xcode 4 introduces snippets triggered by keywords/code completion, but only has placeholders. The other side of the scale quickly went kind of berserk. Of course, there is no interface builder in eclipse. When I first started using the NeXT/Apple Interface Builder, there were little annoyances about it, but very quickly, I became convinced that it was an immensely useful tool, very intelligently implemented. It‘s not that we don‘t have interface builders, it‘s that none of them survived. We wouldn‘t have ORM mapping either if it weren‘t for the fluke of Hibernate growing enough on a crag to get scooped up and watered (the trail of failures there was even deeper). Frankly, as much as I like Hibernate, I seriously don‘t think it‘s that much better than CoreData. But this is my point in this whole jag: only from the warped perspective of ‘hear, let me show you how I have a lead on a bunch of little features‘ can you see eclipse as ahead in this stuff. WTP is still a broken pile of scabs. You can run your app in Tomcat or JBoss, but it will crash and the restarts are painfully slow. The cycle time between source and iPad/iPhone simulators on my SSD-backed MacBook is literally zero and it never crashes.
The new interface builder removes a lot of the prior annoyances. Property and outlet declarations then synthesize statements were a trifecta of repetitive crap. They‘ve really narrowed that stuff down. At SDWest in 2008, Josh Bloch was talking about how painful it is that we have to write declarations like:
List myList = new ArrayList(); (Textile not showing the parameterized classname in both places.. imagine it… )
Eclipse made some progress on that, and now Xcode has too.
But then, what you can really see if you look at Xcode 4 is hordes of disparate tool components from the Java world being scuttled, like so many clattering pieces of broken garbage. Nevermind Git support, they also have blame, logs, diffs, etc., that are miles beyond the horrendous state of half-baked source control plugins. Much as I love Maven, 5 years after adopting it, the plugins are still torture devices. Don‘t need it in xcode. Especially not if a lot of frameworks, etc., adopt git: in the demo, they add github to the repositories pane and then pull code into their project in a few clicks. By the time I saw the new interface testing in Instruments, I was kind of reaching the state of thinking comparison requires things be comparable. People, we are getting to that stage. Seriously..
One last point. Another image appeared to me while I was hypnotized by the flow state. The dominant new framework of the last decade on the Java side was Dependency Injection. The main raison d‘etre of which is the basic idea that newing things all over the place and thus not knowing where and how components are wired together, is bad. How, then, does it make sense that the exteriorization of the wiring ends short of the interface frontier? Watch the Interface Builder demo and you see what explicit wiring looks like that goes from the top to the bottom of the app. There is no bean container, but there‘s no real need for one. Access managed to make a decent interface builder, but it was built atop a sandbox of goofy tinkertoys and figuring out where anything was being done was impossible. This is the gauntlet that Apple has run successfully, and clearly, they are onto a new phase where the tools are subordinate to the overall goal which is the clearest possible expression of the immensely complex elements that go into even the simplest creations.
Sherrod for President
The story of Shirley Sherrod is my favorite news story in ages. Most stories these days show that both sides of the issue or position are rotten to the core. This one delivered that, but then delivered a hero caught between the gnashing gears of diseased machinery. The modern Democratic Party has advanced the belief that they are Progressives, and Republicans are cretins. The first thing most of them point to are social security, medicare, and civil rights. Along comes a quick little episode that shows that whatever ‘progress‘ the Ds gave us, apparently they didn‘t achieve themselves. Rosa Parks was told to sit in the back of the bus. Shirley Sherrod was summarily cashiered before the whole nation, by the administration of the first black president. Mind you, Sherrod is not a hero just because she was a victim. She‘s a hero because she sees what neither of the power-wielding masters do: that the problem isn‘t racism, it‘s justice or, as she put it in her NAACP speech (wait, this story had 3 rotten legs): fairness.
The problem with victim heros is they don‘t solve the fundamental problem. (Freud wrote about this vis a vis Christ v. Mithras in Beyond the Pleasure Principle Their situation may dramatize it and the result may point to the injustice of the oppressors, but that‘s it.
One of the most astounding things about this story was the degree to which the Administration, as usual, doesn‘t see anything in this that even gives them pause about their own position. Speaking of Shakespeare, it‘s clearly the case that this is a stain that will not wash off. The fact that the story started on the Right seems to be all the Left has to offer as a defense for their horrendous behavior.
Finally, how often does a story come along that shows that one of the most obvious conceits of a party in power doesn‘t prevent that power from committing the very crimes they supposedly abhor? The title is only partially joking. The big story out in LA this week was the 3 administrators of the City of Bell who were making as much as $800K/year, looking forward to $600K/year pensions. Spartacus was not much of a philosopher, but the corrupt state of his day was ultimately unable to put down his rebellion: Crassus (the guy who had half the senate in his pocket (he was a ‘lender‘)), had to raise an army. They lined the highway to Rome with crucifixions. I hope Ms. Sherrod tells Vil-sack where he can put his job offer, and some lawyer convinces her that she should pursue a case vs. the government. It would rank with Brown v. Board of Education. Want to end racism? Instead of deeming to turn your own horrible behavior into a ‘teachable moment,‘ maybe it‘s time for a little learning first.
Continuous Deployment at kaChing
Here is the presentation, using the fantastic Prezi tool.
.prezi-player { width: 550px; } .prezi-player-links { text-align: center; }
Continuous Deployment on Prezi
Java Posse #316 - Roundup '10 - Life Beyond JUnit
Life Beyond JUnit Fully formatted shownotes can always be found at http://javaposse.com
Test driven development and automation techniques - recorded at the Java Posse Roundup 2010 in Crested Butte, CO
- Fitnesse
- Slim for Fitnesse
- Cucumber
- RSpec
- EasyB
- Test Driven Development - requirements are testable
- Behavior Driven Development
- Selenium
- Functional testing
- Generated test data
- Useful collection of open source Java testing tools
- Combinatorial explosion
- Regression testing
- Data Transfer Objects
- Code coverage
- Emma - http://emma.sourceforge.net/
- Cobertura - http://cobertura.sourceforge.net/
- Clover - http://www.atlassian.com/software/clover/
- Findbugs
- Infinitest
- ZenTest
- Scala testing tools
- ScalaTest - http://www.artima.com/scalatest/
- ScalaCheck - http://code.google.com/p/scalacheck/
- SBT - http://code.google.com/p/simple-build-tool/
- Five whys to the root cause
- PMD & PMDs copy/paste detector
- Hudson
- Testing deficit
- Libsyn.com - http://www.libsyn.com - for hosting and bandwidth
- Feedburner.com - http://www.feedburner.com - for feed redirect
- Kirsty Doherty, Amy Ehmann for Java Posse artwork
- Theme Music:
- Opening - "Java" the parody song Copyright 1997 Broken Records and Marjorie Music Publ. (BMI),
- written and performed by Loose Bruce Kerr of the Dr. Demento Show and Sun Microsystems attorney.
- Based on the WWI popular song, "Ja-da." Ukelele style on the recording taught to Bruce by his dad.
- Re-produced with kind permission from "Loose" Bruce Kerr - http://loosebrucekerr.libsyn.com http://www.youtube.com/watch?v=TAX0gJt-aZg
- Closing - Juan Carlos Jimenez - In the House (Intro No. 1)
- Opening - "Java" the parody song Copyright 1997 Broken Records and Marjorie Music Publ. (BMI),
- To contact us:
- Visit our homepage - http://javaposse.com
- Post on our Google Group - http://groups.google.com/group/javaposse
- Pose a question on our Google Moderator group - http://tinyurl.com/q4javaposse
- Call us with questions and feedback - (408) 465-4626
- Or send us email - javaposse@gmail.com
The Java Posse consists of Tor Norbye, Carl Quinn, Joe Nuxoll and Dick Wall
A Special Year
The first time I attended JavaOne was 1999 and I have only missed it once since then. Sadly, this year will be the second time I am not present there. I have become kind of used to the week in San Francisco every year. It is the perfect way to start the summer with a visit to that beautiful city. Since it is in September this year, it would probably been the perfect way to end the summer (…we have short summers here in Scandinavia…).
I will for sure miss the massive input and inspiration this conference gives me and enables me to keep up-to-date on everything that is happening in the Java Community. This year’s conference is also special since it is the first time Oracle is hosting the show. It feels like a good idea to co-host it with Oracle Develop and I hope it will be a success to be continued. Next year, I will definitely be attending, one way or the other…!
So You Want to Practice your Code Reviewing Skills? - Summary
The replies were very interesting. Here's a summary
Concurrency/Distribution/Singleton
- instance() method is not synchronized
- sessionCounter needs to be volatile/guarded by synchronization (in visitorCount())
- (Mutable) Singeltons cannot be distributed. is If there is several instance of the webapp running, not all values will be counted because several counter will exist and not be synchronized from JVM to JVM.
- The singleton implementation is broken. See, for instance, this article.
- DataBaseHelperget() method may return the empty string ("") if no rows are in the table, and the singleton only expects a valid number or null, which will cause a NumberFormatException
- the counter may roll over. For a 7 year old web app this is perfectly possible.
- I consider constructs like this catch(Exception e) { sLogger.error("", e); } to be a bug.
- The DB change isn't being committed so it has to rely on the underlying driver's behavior.
- The insert statement doesn't explicitly defines column names, which is susceptible to failure if the order of rows in the DB table changes.
- The update statement updates the row with param = 'SESSION_COUNT' although the insert inserts 'session_count'. Usually this would not work without special set-up in the db and/or connection.
- generateResult() does not close the ResultSet object. Note that the originating Statement object is hidden inside the DataBase.performSqlQuery() method (whose code is not given) so Statement also remains open. The closing of these two objects is deferred to the GC.
- Do not use singletons. A singleton is a smell that indicates the need for dependency injection.
- In general, service objects in web-apps should not maintain state in (plain-old-Java) fields. If you need to have some state, write it to the DB. That's the only way to share state in a distributed settings.
- The nastiest bug of all: the combination of exceptions being silently absorbed, and DataBaseHelper.get() returning an empty string ("") leads to a situation where sessionCounter stays zero, which will reset the visitor count at the DB to 100, thereby loosing the (correct) visitor count.
Here's the scenario: In generateResult() an SqlException if fired (let's say due to a temporary network problem). It is silently caught by generateResult() which then returns an empty list. get() will return an empty string, which will yield a NumberFormatException in reloadParamsFromDB(), which - again - is silently ignored.
Therefore, no assignment to sessionCounter is taking place, so it retains its default value, zero. At the 100th call to addSession() sessionCounter current value (100) will be written to the DB.
Solution: add to the value at the DB instead of writing to it.


