8154304: NullpointerException at LdapReferralException.getReferralContext
Reviewed-by: xuelei, vinnie
--- 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) {