diff --git a/src/main/java/org/apache/commons/math3/exception/util/ExceptionContext.java b/src/main/java/org/apache/commons/math3/exception/util/ExceptionContext.java index a9fd95cec..1a78bd38f 100644 --- a/src/main/java/org/apache/commons/math3/exception/util/ExceptionContext.java +++ b/src/main/java/org/apache/commons/math3/exception/util/ExceptionContext.java @@ -283,12 +283,12 @@ public class ExceptionContext implements Serializable { private void serializeContext(ObjectOutputStream out) throws IOException { // Step 1. - final int len = context.keySet().size(); + final int len = context.size(); out.writeInt(len); - for (String key : context.keySet()) { + for (Map.Entry entry : context.entrySet()) { // Step 2. - out.writeObject(key); - final Object value = context.get(key); + out.writeObject(entry.getKey()); + final Object value = entry.getValue(); if (value instanceof Serializable) { // Step 3a. out.writeObject(value);