A collection of thoughts, ideas and rants inspired by my career in the fintech and banking industry.

Hauppauge 950Q doesn't work with WD Live

According to the Hauppauge website, the Western Digital Live Hub works with the Hauppauge WinTV-HVR-950Q TV tuner. It does not. The Hauppauge app does the channel scan, but freezes when you try to change channels. In other words you have to reboot the WD Live box whenever you want to change channels. That doesn’t count as working in my books. Just sayin’… A bit of Googling has shown that 950Q hardware Rev B may have worked, but the version commonly available in stores is Rev E. [Read More]

@Value not resolved when using @PropertySource annotation.

Spring’s gotcha-of-the-day is around using @Value to resolve property placeholders in combination with @PropertySource. I had the following Spring Java configuration: @Configuration @PropertySource("classpath:/test.properties") public class TestAppConfig { @Value("${queue.name}") private String queue; @Bean(name="queue") public String getQueue() { return queue; } } But the value in “queue” was not resolving - it returned “${queue.name}” as the value. It turns out that I needed the following magical incantation to get it to work. [Read More]
Java  Spring 

Interviewing

I’ve been interviewing candidates quite a bit lately and I must admit that I quite enjoy the process. I get to meet new people and learn about how they work, and things they’ve worked on, and about technologies that I haven’t used or haven’t heard of. At Intelliware we usually conduct two separate interviews: the first is a personality/fit interview intended to answer the questions, “Can we work with this person, and would they be happy here? [Read More]

Scheduled tasks with Spring and Java configs

Spring 3.2 has some very nice features for scheduling tasks. The pure Java way of doing this looks something like private ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); class ScheduledTask implements Runnable { @Override public void run() { System.out.println("Running scheduled task"); } } // Schedule a task every 5 seconds executor.scheduleAtFixedRate(new ScheduledTask(), 1, 5, TimeUnit.SECONDS); // If you don't do this then the JVM won't exit cleanly executor.shutdown(); But now, with the snazzy new Spring scheduling annotations, it can be as simple as this [Read More]
Java  Spring 

Converting from JUnit to TestNG

The TestNG Eclipse plugin has a feature that will convert your unit tests from JUnit to TestNG in a few simple clicks, and it works pretty well for the most part. However, I soon noticed that it was replacing Assert.assertX with AssertJUnit.assertX. Upon further inspection, this was because TestNG’s Assert uses different argument ordering. For example // JUnit Assert.assertEquals(message, expected, actual); // TestNG Assert.assertEquals(actual, expected, message); Each argument has moved. [Read More]

Using Factory Beans in Spring Java Configs

I recently went through an exercise of converting Spring XML configuration files to Java-based configuration. The process went well for the most part, but I encountered an oddity around how to use factory beans when using Java configs. In XML, factory beans would be used like this <bean id="MyDataSource" class="org.springframework.jndi.JndiObjectFactoryBean" p:jndiName="jdbc/MyDataSource" p:resourceRef="false" /> In Java however, this has to be separated into two separate @Beans @Bean public JndiObjectFactoryBean getJndiObjectFactoryBean() { JndiObjectFactoryBean jndi = new JndiObjectFactoryBean(); jndi. [Read More]
Java  Spring 

Atomic construction

Bugs caused by multi-threading can be very difficult to find. Here’s one I encountered recently. private static MyObject INSTANCE; public void init() { if( INSTANCE == null) { initInstance(); } } private static synchronized void initInstance() { if( INSTANCE != null) { return; } INSTANCE = new MyObject(); INSTANCE.initThis(); INSTANCE.initThat(); } At first glance, this code is fine. It uses a synchronized static method to create the singleton, using double-checked locking to make sure it only gets created once. [Read More]

On vlogs

Video blogs, or vlogs, are becoming increasingly popular and if you have a decent following on Twitter/Facebook/etc then you probably also have a YouTube channel from which to pontificate. Vlogs are great. I get to know you a little better because I can hear your accent, the tone of your voice, and see all the non-verbal facial expressions that add so much to any communication. But there are several downsides, too. [Read More]

Moving on

Today is my last day at CIBC and that makes me sad. It’s been an honour and a privilege to work with Mike Salvagna and his fantastic development team for the last 18 months. Mike has assembled one of the best development teams in Toronto that, in his words, “can build anything”. I believe he’s right. Tomorrow I start at Intelliware where I’ll be leading another FX project. I’m looking forward to the challenges that this new position will bring, but I can’t help feeling down about leaving behind such a great team at CIBC. [Read More]

Writing deterministic tests

Non-deterministic unit tests are like kryptonite for an automated build. They cause intermittent build failures and the development team becomes accustomed to ignoring a failing build. This is a Bad Thing. Thread.sleep(x) in a unit test is a recipe for non-deterministic behaviour. Think about what happens when this test is run on a slow machine. How big does X need to be? I often see this anti-pattern in multi-threaded code where the test case is waiting for some asynchronous task to complete, and the test case has to guess at how long the task will take, and then asserts on some condition that the task was supposed to change. [Read More]