| Issue |
Subject |
Date |
| 178
|
WalkingCollection
We look at how we could internalize the iteration into a collection by introducing a Processor interface that is applied to each element. This allows us to manage concurrency from within the collection.
|
2009-11-14
|
| 176
|
The Law of the Xerox Copier
Concurrency is easier when we work with immutable objects. In this newsletter, we define another concurrency law, The Law of the Xerox Copier, which explains how we can work with immutable objects by returning copies from methods that would ordinarily modify the state.
|
2009-09-22
|
| 175
|
Creating Objects Without Calling Constructors
De-Serialization creates objects without calling constructors. We can use the same mechanism to create objects at will, without ever calling their constructors.
|
2009-09-08
|
| 172
|
Wonky Dating
The DateFormat produces some seemingly unpredictable results parsing the date 2009-01-28-09:11:12 as "Sun Nov 30 22:07:51 CET 2008". In this newsletter we examine why and also show how DateFormat reacts to concurrent access.
|
2009-04-23
|
| 171
|
Throwing ConcurrentModificationException Early
One of the hardest exceptions to get rid of in a system is th ConcurrentModificationException, which typically occurs when a thread modifies a collection whilst another is busy iterating. In this newsletter we show how we can fail on the modifying, rather than the iterating thread.
|
2009-03-09
|
| 166
|
Serialization Cache
Java's serialization mechanism is optimized for immutable objects. Writing objects without resetting the stream causes a memory leak. Writing a changed object twice results in only the first state being written. However, resetting the stream also loses the optimization stored in the stream.
|
2008-11-30
|
| 154
|
ResubmittingScheduledPoolExecutor
Timers in Java have suffered from the typical Command Pattern characteristics. Exceptions could stop the timer altogether and even with the new ScheduledPoolExecutor, a task that fails is cancelled. In this newsletter we explore how we could reschedule periodic tasks automatically.
|
2007-12-04
|
| 153
|
Timeout on Console Input
In this newsletter, we look at how we can read from the console input stream, timing out if we do not get a response by some timeout.
|
2007-11-25
|
| 139
|
Mustang ServiceLoader
Mustang introduced a ServiceLoader than can be used to load JDBC drivers (amongst others) simply by including a jar file in your classpath. In this newsletter, we look at how we can use this mechanism to define and load our own services.
|
2007-02-10
|
| 137
|
Creating Loggers DRY-ly
A common idiom for logging is to create a logger in each class that is based on the class name. The name of the class is then duplicated in the class, both in the class definition and in the logger field definition, since the class is for some reason not available from a static context. Read how to solve that problem.
|
2006-12-28
|
| 136
|
Sneaking in JDBC Drivers
In this newsletter, we look at a technique of how we can replace an existing database driver with our own one. This could be used to migrate an application to a new database where you only have the compiled classes. Or it could be used to insert a monitoring JDBC connection that measures the length of database queries.
|
2006-12-11
|
| 132
|
Thread Dump JSP in Java 5
Sometimes it is useful to have a look at what the threads are doing in a light weight fashion in order to discover tricky bugs and bottlenecks. Ideally this should not disturb the performance of the running system. In addition, it should be universally usable and cost nothing. Have a look at how we do it in this newsletter.
|
2006-09-11
|
| 131
|
Sending Emails from Java
In this newsletter, we show how simple it is to send emails from Java. This should obviously not be used for sending unsolicited emails, but will nevertheless illustrate why we are flooded with SPAM.
|
2006-08-28
|
| 128
|
SuDoKu Madness
In this Java Specialists' Newsletter, we look at a simple Java program that solves SuDoKu puzzles.
|
2006-06-21
|
| 122
|
Copying Files from the Internet
Sometimes you need to download files using HTTP from a machine that you cannot run a browser on. In this simple Java program we show you how this is done. We include information of your progress for those who are impatient, and look at how the volatile keyword can be used.
|
2006-03-08
|
| 118
|
A Simple Database Viewer
A simple database viewer written in Java Swing that
reads the metadata and shows you all the tables and contents
of the tables, written in under 100 lines of Java code,
including comments.
|
2005-12-19
|
| 116
|
Closing Database Statements
Don't Repeat Yourself. The mantra of the good Java
programmer. But database code often leads to this
antipattern. Here is a neat simple solution from the
Jakarta Commons DbUtils project.
|
2005-11-28
|
| 086b
|
Initialising Fields before Superconstructor call (Follow-up)
|
2004-03-20
|
| 086
|
Initialising Fields before Superconstructor call
|
2004-03-19
|