Java version now correctly handles empty data.