Using grep to scan project files

Steve Neal Uncategorized Leave a Comment

To find a text pattern in a project, use grep to scan files: the –include directive can be used to select the file types to check (in this case all .properties and .java files), -rnw for recursive with line numbers and word search, the dot is for the current working directory, a finally -e for the regexp to match.

Creating a concurrent Set in Java

Steve Neal Uncategorized Leave a Comment

The concurrent collections are a great help for multi-threaded programming in Java, but there is no concurrent Set class provided in the API. The trick is to use the key set of a ConcurrentHashMap, wrapped by the Set interface. The Collections class provides a static method which will do this for you: Just pass an instance of a ConcurrentHashMap (of …

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 …

Putty and the disappearing cursor

Steve Neal Tool support, Uncategorized Leave a Comment

I’ve had this problem with Putty on and off for years. It’s default black background commonly hides the windows text cursor when the mouse rolls over the terminal window. When this happens I need to rummage around on the internet to find a solution, so I thought I’d make a note of it here on my blog this time instead. …

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. …

Identifying which processes are using network ports on a Mac

Steve Neal Linux Leave a Comment

Typically I’d use netstat’s -o flag to identify the process ID when listing networking activity from a Linux/Unix machine. Unfortunately this option is not available with netstat on ┬áMac OS X. I recently has a rogue process (I suspected a virus) on my Mac that was creating thousands of connections out to hosting providers. Luckily I found this fix, which …

Adding the application name to links in a Web application

Steve Neal Development Leave a Comment

Application servers can run a number of applications. A single Tomcat instance, for example, will create a separate web application for each WAR file it finds in its webapps directory. The applications will be named the same as their WAR files and can be accessed using URLs that start with that name. For example, to access index.jsp in the root …