Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Problem in Andrew's Denny DVD - CleanExit.java?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone:
I think there is a mistake in Andrew's DVD example. Inside the book, it uses 'CleanExit.java' to handle the server shut down. When the user shut down the server, 'CleanExit' will called by the JVM and do some clean up.

Code:
/**
* This method will be executed by the JVM when the application is shutdown.
* It ensures that the database is in a clean state for shutdown (that is,
* there are no outstanding writes occuring).
*/
public void run() {
log.info("Ensuring a clean shutdown");
try {
DvdDatabase database = new DvdDatabase(dbLocation);
database.setDatabaseLocked(true);
} catch (IOException e) {
log.log(Level.SEVERE, "Failed to lock database before exiting", e);
}
}

I assume this is wrong. Because it creates a new database and locks the new database. The real database which has been used by the clients has not been locked for clean up.

Could anyone address please!

Thank you very much!
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only one database can get lock.
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic