noel 2004/03/29 16:37:16 Modified: src/java/org/apache/james/dnsserver Tag: branch_2_1_fcs DNSServer.java Log: Fix JAMES-236. This was a newly introduced problem. The iterator's hasNext() needs to do the work previously deferred to next(), so that we know next() will have a valid return value. Revision Changes Path No revision No revision 1.9.4.13 +15 -8 james-server/src/java/org/apache/james/dnsserver/DNSServer.java Index: DNSServer.java =================================================================== RCS file: /home/cvs/james-server/src/java/org/apache/james/dnsserver/DNSServer.java,v retrieving revision 1.9.4.12 retrieving revision 1.9.4.13 diff -u -r1.9.4.12 -r1.9.4.13 --- DNSServer.java 20 Mar 2004 07:50:42 -0000 1.9.4.12 +++ DNSServer.java 30 Mar 2004 00:37:16 -0000 1.9.4.13 @@ -373,12 +373,14 @@ private Iterator addresses = null; public boolean hasNext() { - return mxHosts.hasNext(); - } - - public Object next() { - if (addresses == null || !addresses.hasNext()) - { + /* Make sure that when next() is called, that we can + * provide a HostAddress. This means that we need to + * have an inner iterator, and verify that it has + * addresses. We could, for example, run into a + * situation where the next mxHost didn't have any valid + * addresses. + */ + if ((addresses == null || !addresses.hasNext()) && mxHosts.hasNext()) do { final String nextHostname = (String)mxHosts.next(); addresses = new Iterator() { private Record[] aRecords = lookup(nextHostname, Type.A); @@ -396,8 +398,13 @@ throw new UnsupportedOperationException ("remove not supported by this iterator"); } }; - } - return addresses.next(); + } while (!addresses.hasNext() && mxHosts.hasNext()); + + return addresses != null && addresses.hasNext(); + } + + public Object next() { + return addresses != null ? addresses.next() : null; } public void remove() {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]