You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Stefano Bagnara <ap...@bago.org> on 2006/12/17 20:25:28 UTC

Re: BACKPORTING : Re: svn commit: r478589 - in /james/server/trunk/src/java/org/apache/james: ./ dnsserver/ services/ smtpserver/core/filter/fastfail/ transport/mailets/ ?

I think you should wait, wait that previous vetoes are resolved.

We could even make all the backport for 2.3.1 when we decide that we 
really want to (need to) do a 2.3.1.

Imho if someone thinks we are ready for 2.3.1 please post a list of 
patch you think should be backported to 2.3 to make the 2.3.1, let's 
discuss a while and let's make this release.

Stefano

Norman Maurer wrote:
> What about backporting the changes ?
> 
> bye
> Norman
> 
> norman@apache.org schrieb:
>> Author: norman
>> Date: Thu Nov 23 06:36:43 2006
>> New Revision: 478589
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=478589
>> Log:
>> Get sure we throw a TemporaryResolutionException on a network error. So we can dedicide what todo in this case. See JAMES-715 and JAMES-31
>>
>> Added:
>>     james/server/trunk/src/java/org/apache/james/dnsserver/TemporaryResolutionException.java   (with props)
>> Modified:
>>     james/server/trunk/src/java/org/apache/james/James.java
>>     james/server/trunk/src/java/org/apache/james/dnsserver/DNSServer.java
>>     james/server/trunk/src/java/org/apache/james/services/DNSServer.java
>>     james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java
>>     james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidSenderDomainHandler.java
>>     james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
>>
>> Modified: james/server/trunk/src/java/org/apache/james/James.java
>> URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/James.java?view=diff&rev=478589&r1=478588&r2=478589
>> ==============================================================================
>> --- james/server/trunk/src/java/org/apache/james/James.java (original)
>> +++ james/server/trunk/src/java/org/apache/james/James.java Thu Nov 23 06:36:43 2006
>> @@ -39,6 +39,7 @@
>>  import org.apache.james.core.MailHeaders;
>>  import org.apache.james.core.MailImpl;
>>  import org.apache.james.core.MailetConfigImpl;
>> +import org.apache.james.dnsserver.TemporaryResolutionException;
>>  import org.apache.james.services.DNSServer;
>>  import org.apache.james.services.DomainList;
>>  import org.apache.james.services.FileSystem;
>> @@ -66,7 +67,9 @@
>>  import java.io.ByteArrayInputStream;
>>  import java.io.InputStream;
>>  import java.io.SequenceInputStream;
>> +import java.util.ArrayList;
>>  import java.util.Collection;
>> +import java.util.Collections;
>>  import java.util.Date;
>>  import java.util.Enumeration;
>>  import java.util.HashSet;
>> @@ -579,7 +582,12 @@
>>       * @see org.apache.mailet.MailetContext#getMailServers(String)
>>       */
>>      public Collection getMailServers(String host) {
>> -        return lookupDNSServer().findMXRecords(host);
>> +        try {
>> +            return lookupDNSServer().findMXRecords(host);
>> +        } catch (TemporaryResolutionException e) {
>> +            //TODO: We only do this to not break backward compatiblity. Should fixed later
>> +            return Collections.unmodifiableCollection(new ArrayList(0));
>> +        }
>>      }
>>  
>>      /**
>> @@ -834,7 +842,12 @@
>>       * @return an Iterator over HostAddress instances, sorted by priority
>>       */
>>      public Iterator getSMTPHostAddresses(String domainName) {
>> -        return lookupDNSServer().getSMTPHostAddresses(domainName);
>> +        try {
>> +            return lookupDNSServer().getSMTPHostAddresses(domainName);
>> +        } catch (TemporaryResolutionException e) {
>> +            //TODO: We only do this to not break backward compatiblity. Should fixed later
>> +            return Collections.unmodifiableCollection(new ArrayList(0)).iterator();
>> +        }
>>      }
>>  
>>      protected DNSServer lookupDNSServer() {
>>
>> Modified: james/server/trunk/src/java/org/apache/james/dnsserver/DNSServer.java
>> URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/dnsserver/DNSServer.java?view=diff&rev=478589&r1=478588&r2=478589
>> ==============================================================================
>> --- james/server/trunk/src/java/org/apache/james/dnsserver/DNSServer.java (original)
>> +++ james/server/trunk/src/java/org/apache/james/dnsserver/DNSServer.java Thu Nov 23 06:36:43 2006
>> @@ -257,8 +257,9 @@
>>       * @param hostname domain name to look up
>>       *
>>       * @return a list of MX records corresponding to this mail domain
>> +     * @throws TemporaryResolutionException get thrown on temporary problems
>>       */
>> -    private List findMXRecordsRaw(String hostname) {
>> +    private List findMXRecordsRaw(String hostname) throws TemporaryResolutionException {
>>          Record answers[] = lookup(hostname, Type.MX, "MX");
>>          List servers = new ArrayList();
>>          if (answers == null) {
>> @@ -282,7 +283,7 @@
>>      /**
>>       * @see org.apache.james.services.DNSServer#findMXRecords(String)
>>       */
>> -    public Collection findMXRecords(String hostname) {
>> +    public Collection findMXRecords(String hostname) throws TemporaryResolutionException {
>>          List servers = new ArrayList();
>>          try {
>>              servers = findMXRecordsRaw(hostname);
>> @@ -324,16 +325,24 @@
>>       * @param type the type of record desired
>>       * @param typeDesc the description of the record type, for debugging purpose
>>       */
>> -    protected Record[] lookup(String namestr, int type, String typeDesc) {
>> +    protected Record[] lookup(String namestr, int type, String typeDesc) throws TemporaryResolutionException {
>>          // Name name = null;
>>          try {
>>              // name = Name.fromString(namestr, Name.root);
>>              Lookup l = new Lookup(namestr, type);
>> +            
>>              l.setCache(cache);
>>              l.setResolver(resolver);
>>              l.setCredibility(dnsCredibility);
>>              l.setSearchPath(searchPaths);
>> -            return l.run();
>> +            Record[] r = l.run();
>> +            
>> +            if (l.getResult() == Lookup.TRY_AGAIN) {
>> +                throw new TemporaryResolutionException("DNSServer is temporary not reachable");
>> +            } else {
>> +                return r;
>> +            }
>> +            
>>              // return rawDNSLookup(name, false, type, typeDesc);
>>          } catch (TextParseException tpe) {
>>              // TODO: Figure out how to handle this correctly.
>> @@ -342,6 +351,14 @@
>>          }
>>      }
>>      
>> +    protected Record[] lookupNoException(String namestr, int type, String typeDesc) {
>> +        try {
>> +            return lookup(namestr, type, typeDesc);
>> +        } catch (TemporaryResolutionException e) {
>> +            return null;
>> +        }
>> +    }
>> +    
>>      /* RFC 2821 section 5 requires that we sort the MX records by their
>>       * preference, and introduce a randomization.  This Comparator does
>>       * comparisons as normal unless the values are equal, in which case
>> @@ -371,7 +388,7 @@
>>      /**
>>       * @see org.apache.james.services.DNSServer#getSMTPHostAddresses(String)
>>       */
>> -    public Iterator getSMTPHostAddresses(final String domainName) {
>> +    public Iterator getSMTPHostAddresses(final String domainName) throws TemporaryResolutionException {
>>          return new Iterator() {
>>              private Iterator mxHosts = findMXRecords(domainName).iterator();
>>              private Iterator addresses = null;
>> @@ -469,7 +486,8 @@
>>          try {
>>              return org.xbill.DNS.Address.getByAddress(name);
>>          } catch (UnknownHostException e) {
>> -            Record [] records = lookup(name, Type.A, "A");
>> +            Record[] records = lookupNoException(name, Type.A, "A");
>> +
>>              if (records != null && records.length >= 1) {
>>                  ARecord a = (ARecord) records[0];
>>                  return InetAddress.getByAddress(name, a.getAddress().getAddress());
>> @@ -486,7 +504,8 @@
>>              InetAddress addr = org.xbill.DNS.Address.getByAddress(name);
>>              return new InetAddress[] {addr};
>>          } catch (UnknownHostException e) {
>> -            Record [] records = lookup(name, Type.A, "A");
>> +            Record[] records = lookupNoException(name, Type.A, "A");
>> +            
>>              if (records != null && records.length >= 1) {
>>                  InetAddress [] addrs = new InetAddress[records.length];
>>                  for (int i = 0; i < records.length; i++) {
>> @@ -503,9 +522,7 @@
>>       */
>>      public Collection findTXTRecords(String hostname){
>>          List txtR = new ArrayList();
>> -        Record[] records;
>> -        
>> -        records = lookup(hostname, Type.TXT, "TXT");
>> +        Record[] records = lookupNoException(hostname, Type.TXT, "TXT");
>>      
>>          if (records != null) {
>>             for (int i = 0; i < records.length; i++) {
>> @@ -523,7 +540,8 @@
>>      public String getHostName(InetAddress addr){
>>          String result = null;
>>          Name name = ReverseMap.fromAddress(addr);
>> -        Record [] records = lookup(name.toString(), Type.PTR, "PTR");
>> +        Record[] records = lookupNoException(name.toString(), Type.PTR, "PTR");
>> +
>>          if (records == null) {
>>              result = addr.getHostAddress();
>>          } else {
>>
>> Added: james/server/trunk/src/java/org/apache/james/dnsserver/TemporaryResolutionException.java
>> URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/dnsserver/TemporaryResolutionException.java?view=auto&rev=478589
>> ==============================================================================
>> --- james/server/trunk/src/java/org/apache/james/dnsserver/TemporaryResolutionException.java (added)
>> +++ james/server/trunk/src/java/org/apache/james/dnsserver/TemporaryResolutionException.java Thu Nov 23 06:36:43 2006
>> @@ -0,0 +1,36 @@
>> +/****************************************************************
>> + * Licensed to the Apache Software Foundation (ASF) under one   *
>> + * or more contributor license agreements.  See the NOTICE file *
>> + * distributed with this work for additional information        *
>> + * regarding copyright ownership.  The ASF licenses this file   *
>> + * to you under the Apache License, Version 2.0 (the            *
>> + * "License"); you may not use this file except in compliance   *
>> + * with the License.  You may obtain a copy of the License at   *
>> + *                                                              *
>> + *   http://www.apache.org/licenses/LICENSE-2.0                 *
>> + *                                                              *
>> + * Unless required by applicable law or agreed to in writing,   *
>> + * software distributed under the License is distributed on an  *
>> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
>> + * KIND, either express or implied.  See the License for the    *
>> + * specific language governing permissions and limitations      *
>> + * under the License.                                           *
>> + ****************************************************************/
>> +
>> +
>> +
>> +
>> +package org.apache.james.dnsserver;
>> +
>> +import java.io.IOException;
>> +
>> +public class TemporaryResolutionException extends IOException {
>> +
>> +    public TemporaryResolutionException() {
>> +        super();
>> +    }
>> +
>> +    public TemporaryResolutionException(String message) {
>> +        super(message);
>> +    }
>> +}
>>
>> Propchange: james/server/trunk/src/java/org/apache/james/dnsserver/TemporaryResolutionException.java
>> ------------------------------------------------------------------------------
>>     svn:eol-style = native
>>
>> Modified: james/server/trunk/src/java/org/apache/james/services/DNSServer.java
>> URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/services/DNSServer.java?view=diff&rev=478589&r1=478588&r2=478589
>> ==============================================================================
>> --- james/server/trunk/src/java/org/apache/james/services/DNSServer.java (original)
>> +++ james/server/trunk/src/java/org/apache/james/services/DNSServer.java Thu Nov 23 06:36:43 2006
>> @@ -26,6 +26,8 @@
>>  import java.util.Collection;
>>  import java.util.Iterator;
>>  
>> +import org.apache.james.dnsserver.TemporaryResolutionException;
>> +
>>  /**
>>   * Provides abstraction for DNS resolutions. The interface is Mail specific.
>>   * It may be a good idea to make the interface more generic or expose 
>> @@ -50,8 +52,9 @@
>>       *
>>       * @return a unmodifiable list of handling servers corresponding to
>>       *         this mail domain name
>> +     * @throws TemporaryResolutionException get thrown on temporary problems 
>>       */
>> -    Collection findMXRecords(String hostname);
>> +    Collection findMXRecords(String hostname) throws TemporaryResolutionException;
>>  
>>      /**
>>       * Get a collection of DNS TXT Records
>> @@ -78,8 +81,9 @@
>>       * @since v2.2.0a16-unstable
>>       * @param domainName - the domain for which to find mail servers
>>       * @return an Iterator over HostAddress instances, sorted by priority
>> +     * @throws TemporaryResolutionException get thrown on temporary problems
>>       */
>> -    Iterator getSMTPHostAddresses(String domainName);
>> +    Iterator getSMTPHostAddresses(String domainName) throws TemporaryResolutionException;
>>      
>>      /**
>>       * @see java.net.InetAddress#getAllByName(String)
>>
>> Modified: james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java
>> URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java?view=diff&rev=478589&r1=478588&r2=478589
>> ==============================================================================
>> --- james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java (original)
>> +++ james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java Thu Nov 23 06:36:43 2006
>> @@ -30,6 +30,7 @@
>>  import org.apache.avalon.framework.service.ServiceException;
>>  import org.apache.avalon.framework.service.ServiceManager;
>>  import org.apache.avalon.framework.service.Serviceable;
>> +import org.apache.james.dnsserver.TemporaryResolutionException;
>>  import org.apache.james.services.DNSServer;
>>  import org.apache.james.smtpserver.CommandHandler;
>>  import org.apache.james.smtpserver.SMTPSession;
>> @@ -140,9 +141,14 @@
>>          // Email should be deliver local
>>          if (domain.equals(LOCALHOST)) return false;
>>   
>> -        Iterator mx = dnsServer.findMXRecords(domain).iterator();
>> +        Iterator mx = null;
>> +        try {
>> +            mx = dnsServer.findMXRecords(domain).iterator();
>> +        } catch (TemporaryResolutionException e1) {
>> +            //  TODO: Should we reject temporary ?
>> +        }
>>  
>> -        if (mx.hasNext()) {
>> +        if (mx != null && mx.hasNext()) {
>>              while (mx.hasNext()) {
>>                  String mxRec = mx.next().toString();
>>  
>>
>> Modified: james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidSenderDomainHandler.java
>> URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidSenderDomainHandler.java?view=diff&rev=478589&r1=478588&r2=478589
>> ==============================================================================
>> --- james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidSenderDomainHandler.java (original)
>> +++ james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/ValidSenderDomainHandler.java Thu Nov 23 06:36:43 2006
>> @@ -30,6 +30,7 @@
>>  import org.apache.avalon.framework.service.ServiceException;
>>  import org.apache.avalon.framework.service.ServiceManager;
>>  import org.apache.avalon.framework.service.Serviceable;
>> +import org.apache.james.dnsserver.TemporaryResolutionException;
>>  import org.apache.james.services.DNSServer;
>>  import org.apache.james.smtpserver.CommandHandler;
>>  import org.apache.james.smtpserver.SMTPSession;
>> @@ -103,11 +104,16 @@
>>           * don't check if the ip address is allowed to relay. Only check if it is set in the config. 
>>           */
>>          if (checkAuthClients || !session.isRelayingAllowed()) {
>> -            Collection records;
>> +            Collection records = null;
>>              
>>                  
>>              // try to resolv the provided domain in the senderaddress. If it can not resolved do not accept it.
>> -            records = dnsServer.findMXRecords(senderAddress.getHost());
>> +            try {
>> +                records = dnsServer.findMXRecords(senderAddress.getHost());
>> +            } catch (TemporaryResolutionException e) {
>> +                // TODO: Should we reject temporary ?
>> +            }
>> +        
>>              if (records == null || records.size() == 0) {
>>                  return true;
>>              }
>>
>> Modified: james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
>> URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java?view=diff&rev=478589&r1=478588&r2=478589
>> ==============================================================================
>> --- james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java (original)
>> +++ james/server/trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java Thu Nov 23 06:36:43 2006
>> @@ -27,6 +27,7 @@
>>  import org.apache.avalon.framework.service.ServiceException;
>>  import org.apache.avalon.framework.service.ServiceManager;
>>  import org.apache.james.Constants;
>> +import org.apache.james.dnsserver.TemporaryResolutionException;
>>  import org.apache.james.services.DNSServer;
>>  import org.apache.james.services.SpoolRepository;
>>  import org.apache.james.util.TimeConverter;
>> @@ -458,7 +459,19 @@
>>                  String host = rcpt.getHost();
>>  
>>                  //Lookup the possible targets
>> -                targetServers = getMailetContext().getSMTPHostAddresses(host);
>> +                try {
>> +                    targetServers = dnsServer.getSMTPHostAddresses(host);
>> +                } catch (TemporaryResolutionException e) {
>> +                    log("Temporary problem looking up mail server for host: " + host);
>> +                    StringBuffer exceptionBuffer =
>> +                        new StringBuffer(128)
>> +                        .append("Temporary problem looking up mail server for host: ")
>> +                        .append(host)
>> +                        .append(".  I cannot determine where to send this message.");
>> +                    
>> +                    // temporary problems
>> +                    return failMessage(mail, new MessagingException(exceptionBuffer.toString()), false);
>> +                }
>>                  if (!targetServers.hasNext()) {
>>                      log("No mail server found for: " + host);
>>                      StringBuffer exceptionBuffer =
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
>> For additional commands, e-mail: server-dev-help@james.apache.org
>>
>> !EXCUBATOR:1,4565b22a53077467620893!
>>   
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org