8191142: More refactoring for naming deserialization cases
Reviewed-by: chegar, rriggs
--- a/src/java.naming/share/classes/javax/naming/directory/BasicAttributes.java Mon Nov 27 17:30:49 2017 -0800
+++ b/src/java.naming/share/classes/javax/naming/directory/BasicAttributes.java Wed Nov 29 13:56:06 2017 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -302,8 +302,8 @@
s.defaultReadObject(); // read in the ignoreCase flag
int n = s.readInt(); // number of attributes
attrs = (n >= 1)
- ? new Hashtable<String,Attribute>(n * 2)
- : new Hashtable<String,Attribute>(2); // can't have initial size of 0 (grrr...)
+ ? new Hashtable<>(1 + (int) (Math.min(768, n) / .75f))
+ : new Hashtable<>(2); // can't have initial size of 0 (grrr...)
while (--n >= 0) {
put((Attribute)s.readObject());
}