# HG changeset patch # User xuelei # Date 1369792033 25200 # Node ID 5d515b9ffbbe6857f0747e9bb261e968e588fc9e # Parent 3d31ab54bbc5afdc1e35a56f4c444f66bc6dce54 8010815: some constructors issues in com.sun.jndi.toolkit Reviewed-by: alanb diff -r 3d31ab54bbc5 -r 5d515b9ffbbe jdk/src/share/classes/com/sun/jndi/toolkit/ctx/Continuation.java --- a/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/Continuation.java Tue May 28 14:02:49 2013 -0700 +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/Continuation.java Tue May 28 18:47:13 2013 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -90,14 +90,16 @@ * Constructs a new instance of Continuation. * @param top The name of the object that is to be resolved/operated upon. * This becomes the Continuation's 'starter' and is used to - * calculate the "resolved name" when filling in a NamingException. + * calculate the "resolved name" when filling in a NamingException. * @param environment The environment used by the caller. It is used - * when setting the "environment" of a CannotProceedException. + * when setting the "environment" of a CannotProceedException. */ + @SuppressWarnings("unchecked") // For Hashtable clone: environment.clone() public Continuation(Name top, Hashtable environment) { super(); starter = top; - this.environment = environment; + this.environment = (Hashtable) + ((environment == null) ? null : environment.clone()); } /** diff -r 3d31ab54bbc5 -r 5d515b9ffbbe jdk/src/share/classes/com/sun/jndi/toolkit/dir/LazySearchEnumerationImpl.java --- a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/LazySearchEnumerationImpl.java Tue May 28 14:02:49 2013 -0700 +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/LazySearchEnumerationImpl.java Tue May 28 18:47:13 2013 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -69,6 +69,7 @@ } } + @SuppressWarnings("unchecked") // For Hashtable clone: env.clone() public LazySearchEnumerationImpl(NamingEnumeration candidates, AttrFilter filter, SearchControls cons, Context ctx, Hashtable env, boolean useFactory) @@ -76,7 +77,8 @@ this.candidates = candidates; this.filter = filter; - this.env = env; + this.env = (Hashtable) + ((env == null) ? null : env.clone()); this.context = ctx; this.useFactory = useFactory; diff -r 3d31ab54bbc5 -r 5d515b9ffbbe jdk/src/share/classes/com/sun/jndi/toolkit/url/GenericURLContext.java --- a/jdk/src/share/classes/com/sun/jndi/toolkit/url/GenericURLContext.java Tue May 28 14:02:49 2013 -0700 +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/url/GenericURLContext.java Tue May 28 18:47:13 2013 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -53,7 +53,8 @@ @SuppressWarnings("unchecked") // Expect Hashtable public GenericURLContext(Hashtable env) { // context that is not tied to any specific URL - myEnv = (Hashtable)env; // copied on write + myEnv = + (Hashtable)(env == null ? null : env.clone()); } public void close() throws NamingException { @@ -488,22 +489,19 @@ return result; } - @SuppressWarnings("unchecked") // clone() public Object removeFromEnvironment(String propName) throws NamingException { if (myEnv == null) { return null; } - myEnv = (Hashtable)myEnv.clone(); return myEnv.remove(propName); } - @SuppressWarnings("unchecked") // clone() public Object addToEnvironment(String propName, Object propVal) throws NamingException { - myEnv = (myEnv == null) - ? new Hashtable(11, 0.75f) - : (Hashtable)myEnv.clone(); + if (myEnv == null) { + myEnv = new Hashtable(11, 0.75f); + } return myEnv.put(propName, propVal); }