mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
two bug fixes.
This commit is contained in:
parent
d7314ba80a
commit
c366d5e1d6
@ -131,8 +131,11 @@ public class LDAPAttribute {
|
||||
synchronized(this) {
|
||||
try {
|
||||
for (int i=0; i<values.length; i++) {
|
||||
if ( values[i] != null )
|
||||
if ( values[i] != null ) {
|
||||
v.addElement(new String ((byte[])values[i], "UTF8"));
|
||||
} else {
|
||||
v.addElement( new String( "" ) );
|
||||
}
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
return null;
|
||||
@ -151,8 +154,11 @@ public class LDAPAttribute {
|
||||
Vector v = new Vector();
|
||||
synchronized(this) {
|
||||
for (int i=0; i<values.length; i++) {
|
||||
if ( values[i] != null )
|
||||
if ( values[i] != null ) {
|
||||
v.addElement(values[i]);
|
||||
} else {
|
||||
v.addElement( new byte[0] );
|
||||
}
|
||||
}
|
||||
}
|
||||
return v.elements();
|
||||
|
@ -3157,6 +3157,12 @@ public class LDAPConnection implements LDAPv3, Cloneable {
|
||||
return;
|
||||
}
|
||||
setOption(option, value, defaultConstraints);
|
||||
if ( (option == MAXBACKLOG) && (th != null) ) {
|
||||
int val = ((Integer)value).intValue();
|
||||
if ( val >= 1 ) {
|
||||
th.setMaxBacklog( val );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setOption( int option, Object value, LDAPSearchConstraints cons ) throws LDAPException {
|
||||
@ -3949,6 +3955,7 @@ class LDAPConnThread extends Thread {
|
||||
sufficient privileges to connect to the desired host */
|
||||
if (factory == null) {
|
||||
m_socket = new Socket (host, port);
|
||||
// m_socket.setSoLinger( false, -1 );
|
||||
} else {
|
||||
m_socket = factory.makeSocket(host, port);
|
||||
}
|
||||
|
@ -330,14 +330,20 @@ public class LDAPSearchConstraints implements Cloneable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set and get the maximum number of unread entries any search listener can
|
||||
* Set the maximum number of unread entries any search listener can
|
||||
* have before we stop reading from the server.
|
||||
* @param backlog The maximum number of unread entries per listener
|
||||
*/
|
||||
void setMaxBacklog( int backlog ) {
|
||||
public void setMaxBacklog( int backlog ) {
|
||||
m_maxBacklog = backlog;
|
||||
}
|
||||
|
||||
int getMaxBacklog() {
|
||||
/**
|
||||
* Get the maximum number of unread entries any search listener can
|
||||
* have before we stop reading from the server.
|
||||
* @return The maximum number of unread entries per listener
|
||||
*/
|
||||
public int getMaxBacklog() {
|
||||
return m_maxBacklog;
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@ public class LDAPSearchResults implements Enumeration {
|
||||
private String[] currAttrs;
|
||||
private boolean currAttrsOnly;
|
||||
private Vector referralResults = new Vector();
|
||||
private Vector exceptions;
|
||||
|
||||
// only used for the persistent search
|
||||
private boolean firstResult = false;
|
||||
@ -141,12 +142,17 @@ public class LDAPSearchResults implements Enumeration {
|
||||
void add( JDAPSearchResultReference sr ) {
|
||||
/* convert to LDAPReferralException */
|
||||
String urls[] = sr.getUrls();
|
||||
if (urls != null)
|
||||
entries.addElement(new LDAPReferralException(null, 0, urls));
|
||||
if (urls != null) {
|
||||
if (exceptions == null)
|
||||
exceptions = new Vector();
|
||||
exceptions.addElement(new LDAPReferralException(null, 0, urls));
|
||||
}
|
||||
}
|
||||
|
||||
void add(LDAPException e) {
|
||||
entries.addElement(e);
|
||||
if (exceptions == null)
|
||||
exceptions = new Vector();
|
||||
exceptions.addElement(e);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -366,6 +372,12 @@ public class LDAPSearchResults implements Enumeration {
|
||||
return nextReferralElement();
|
||||
}
|
||||
|
||||
if ((exceptions != null) && (exceptions.size() > 0)) {
|
||||
Object obj = exceptions.elementAt(0);
|
||||
exceptions.removeElementAt(0);
|
||||
return obj;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -411,16 +423,20 @@ public class LDAPSearchResults implements Enumeration {
|
||||
while ((entries.size() == 0) && (!searchComplete))
|
||||
fetchResult();
|
||||
|
||||
while (referralResults.size() > 0) {
|
||||
LDAPSearchResults res =
|
||||
(LDAPSearchResults)referralResults.elementAt(0);
|
||||
if (res.hasMoreElements())
|
||||
return true;
|
||||
else
|
||||
referralResults.removeElementAt(0);
|
||||
if ((entries.size() == 0) &&
|
||||
((exceptions == null) || (exceptions.size() == 0))) {
|
||||
while (referralResults.size() > 0) {
|
||||
LDAPSearchResults res =
|
||||
(LDAPSearchResults)referralResults.elementAt(0);
|
||||
if (res.hasMoreElements())
|
||||
return true;
|
||||
else
|
||||
referralResults.removeElementAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
return (entries.size() > 0);
|
||||
return ((entries.size() > 0) ||
|
||||
((exceptions != null) && (exceptions.size() > 0)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -434,6 +450,9 @@ public class LDAPSearchResults implements Enumeration {
|
||||
(LDAPSearchResults)referralResults.elementAt(i);
|
||||
totalReferralEntries = totalReferralEntries+res.getCount();
|
||||
}
|
||||
|
||||
if (exceptions != null)
|
||||
return (entries.size() + exceptions.size() + totalReferralEntries);
|
||||
return (entries.size() + totalReferralEntries);
|
||||
}
|
||||
|
||||
@ -442,7 +461,7 @@ public class LDAPSearchResults implements Enumeration {
|
||||
* @return Message id.
|
||||
*/
|
||||
int getID() {
|
||||
if ( (resultSource == null) || searchComplete )
|
||||
if ( resultSource == null )
|
||||
return -1;
|
||||
return resultSource.getID();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user