Securing an Apache Ignite cluster

Steve Neal Development, Java Programming 4 Comments

I’ve been building a data grid at an investment bank using Apache Ignite and have had a tough time securing it. The documentation for Ignite is really very good but doesn’t touch on how to secure a cluster at all. In this blog I’ll give an overview of how to secure a cluster in the hope that it will prove …

A genuinely type safe Map for Java

Steve Neal Java Programming Leave a Comment

The problem: As much as I love generics in Java, it is still necessary to employ evil casts when retrieving different data types from a Map; see lines 13, 14 and 15: Did you spot the bug in this example? The compiler would have missed it. Ideally, I’d much rather work with code like this: In addition to the casts …

Providing a default exception handling strategy in Java applications

Steve Neal Development, Java Programming 2 Comments

When writing a Java application you may need to consider how that application should react when an uncaught exception is encountered. Generally, when an exception is not handled, the threads stack trace is printed to the error stream and the throwing thread dies; potentially causing the application to shut down if there are no other active (or daemon) threads running. …

Adding a thread timeout to methods in Java

Steve Neal Development, Java Programming 1 Comment

When calling a method that could potentially take longer that you’d like to complete, it is possible to write code that will back out after a given time period. This can happen in numerous circumstances where you’d like an application to maintain a degree of liveness. I’ve used it recently in an application that needed to run a number of …

What info can you get from an HttpServletRequest?

Steve Neal Development, Java Programming Leave a Comment

There are many methods on an HttpServletRequest, and if you’re anything like me, you’ll forget exactly what each of them returns. Rather than a long winded investigation into them all, here’s a sample URL: https://localhost:8443/test/welcome?a=1&b=2 The ‘/test’ in the URL will map to a servlet called test. The servlet will dispatch the request to a JSP for rendering that has …

Implementing Flash Scope in Java Web Applications

Steve Neal Development, Java Programming 6 Comments

While working recently on a Spring MVC project I found myself wishing it supported flash scope. I hunted around for a simple solution but couldn’t find anything that didn’t rely on having to import large framework libraries. After a little thought I came up with the following simple and lightweight solution that has worked really well for me. I’ve included …

Getting a “Netscape security model is no longer supported” error when using IntelliJ

Steve Neal Java Programming 1 Comment

I’ve been working on a JMS application that uses encryption with JNDI authentication and have encountered the following error message when running it: Netscape security model is no longer supported. Please migrate to the Java 2 security model instead. It turns out that this is a problem with the JDK’s plugin.jar file and can be fixed quite easily by removing …

Using Mockito to Unit Test Java Applications

Steve Neal Development, Java Programming, Tool support 23 Comments

If you’ve spent any time writing unit tests then you’ll know that it’s not always straight-forward. Certain things are inherently hard to test. In this post I’ll show you the basic principles of creating mock objects with a little help from the Mockito mocking tool. One common problem faced when unit testing is how to test one object when it …