8154304: NullpointerException at LdapReferralException.getReferralContext
authorcoffeys
Sat, 16 Apr 2016 13:14:38 +0100
changeset 37367 9bddc1afb3b0
parent 37366 2a9763cab068
child 37368 bf9b868f1aa8
8154304: NullpointerException at LdapReferralException.getReferralContext Reviewed-by: xuelei, vinnie
jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapReferralContext.java
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapReferralContext.java	Sat Apr 16 01:23:54 2016 +0000
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapReferralContext.java	Sat Apr 16 13:14:38 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, 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
@@ -92,7 +92,12 @@
             try {
                 referral = refEx.getNextReferral();
                 if (referral == null) {
-                    throw (NamingException)(previousEx.fillInStackTrace());
+                    if (previousEx != null) {
+                        throw (NamingException)(previousEx.fillInStackTrace());
+                    } else {
+                        throw new NamingException(
+                            "Illegal encoding: referral is empty");
+                    }
                 }
 
             } catch (LdapReferralException e) {