diff --git a/src/java/Authentication.java b/src/java/Authentication.java index 54928d8..515dc90 100644 --- a/src/java/Authentication.java +++ b/src/java/Authentication.java @@ -33,6 +33,9 @@ public void registerUser(String username, String password) { // BUG: No null checks - will throw NullPointerException // BUG: Plain text password comparison - SECURITY ISSUE public boolean login(String username, String password) { + if (username == null || password == null) { + return false; + } String storedPassword = users.get(username); boolean isValid = storedPassword.equals(password); diff --git a/src/java/DataProcessor.java b/src/java/DataProcessor.java index 14d9441..0209832 100644 --- a/src/java/DataProcessor.java +++ b/src/java/DataProcessor.java @@ -34,7 +34,10 @@ public void wirteFile(String filepath, List data) throws IOException { // BUG: Returns 0 for empty list without indication public double calculateMean(List numbers) { if (numbers.isEmpty()) { - return 0; + throw new ArithmeticException("List is empty"); + } + if (numbers.size() == 0) { + throw new ArithmeticException("List is empty"); } double sum = 0; for (double num : numbers) {