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 Norman Maurer <no...@apache.org> on 2008/03/24 16:29:33 UTC

Re: svn commit: r640354 - in /james/server/trunk: core-library/src/main/java/org/apache/james/mailboxmanager/ imap-api/src/main/java/org/apache/james/api/imap/message/request/ imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev...

Hi Robert,

is there any reason for this line  (NioUtils) : 

+        "HEllo".getBytes();


Cheers,
Norman

Am Montag, den 24.03.2008, 09:14 +0000 schrieb rdonkin@apache.org:
> Author: rdonkin
> Date: Mon Mar 24 02:14:55 2008
> New Revision: 640354
> 
> URL: http://svn.apache.org/viewvc?rev=640354&view=rev
> Log:
> Fix problems with older JREs
> 
> Added:
>     james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/NioUtils.java
> Modified:
>     james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/SearchQuery.java
>     james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java
>     james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev1/server/SearchResponse.java
>     james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserCharsetTest.java
>     james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserQuotedCharsetTest.java
>     james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserTopLevelAndTest.java
>     james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/FetchProcessor.java
>     james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/MessageSearches.java
> 
> Modified: james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/SearchQuery.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/SearchQuery.java?rev=640354&r1=640353&r2=640354&view=diff
> ==============================================================================
> --- james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/SearchQuery.java (original)
> +++ james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/SearchQuery.java Mon Mar 24 02:14:55 2008
> @@ -1600,10 +1600,7 @@
>           */
>          //@Override
>          public int hashCode() {
> -            final int PRIME = 31;
> -            int result = 1;
> -            result = PRIME * result + Arrays.hashCode(range);
> -            return result;
> +            return range.length;
>          }
>  
>          /**
> 
> Modified: james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java?rev=640354&r1=640353&r2=640354&view=diff
> ==============================================================================
> --- james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java (original)
> +++ james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java Mon Mar 24 02:14:55 2008
> @@ -382,7 +382,7 @@
>          int result = 1;
>          result = PRIME * result + ((date == null) ? 0 : date.hashCode());
>          result = PRIME * result + ((name == null) ? 0 : name.hashCode());
> -        result = PRIME * result + Arrays.hashCode(sequence);
> +        result = PRIME * result + sequence.length;
>          result = PRIME * result + (int) (size ^ (size >>> 32));
>          result = PRIME * result + ((keys == null) ? 0 : keys.hashCode());
>          result = PRIME * result + type;
> 
> Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev1/server/SearchResponse.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev1/server/SearchResponse.java?rev=640354&r1=640353&r2=640354&view=diff
> ==============================================================================
> --- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev1/server/SearchResponse.java (original)
> +++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imap/message/response/imap4rev1/server/SearchResponse.java Mon Mar 24 02:14:55 2008
> @@ -51,10 +51,7 @@
>       */
>      //@Override
>      public int hashCode() {
> -        final int PRIME = 31;
> -        int result = 1;
> -        result = PRIME * result + Arrays.hashCode(ids);
> -        return result;
> +        return ids.length;
>      }
>  
>      /**
> 
> Added: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/NioUtils.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/NioUtils.java?rev=640354&view=auto
> ==============================================================================
> --- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/NioUtils.java (added)
> +++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/NioUtils.java Mon Mar 24 02:14:55 2008
> @@ -0,0 +1,42 @@
> +/****************************************************************
> + * 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.imapserver.codec.decode.imap4rev1;
> +
> +import java.nio.ByteBuffer;
> +import java.nio.charset.Charset;
> +
> +public class NioUtils {
> +
> +    public static final byte[] toBytes(String string, Charset charset) {
> +        ByteBuffer buffer = charset.encode(string);
> +        byte[] results = new byte[buffer.limit()];
> +        buffer.get(results);
> +        "HEllo".getBytes();
> +        return results;
> +    }
> +
> +    public static final byte[] add(byte[] one, byte[] two) {
> +        byte[] results = new byte[one.length + two.length];
> +        System.arraycopy(one, 0, results, 0, one.length);
> +        System.arraycopy(two, 0, results, one.length, two.length);
> +        return results;
> +    }
> +
> +}
> 
> Modified: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserCharsetTest.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserCharsetTest.java?rev=640354&r1=640353&r2=640354&view=diff
> ==============================================================================
> --- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserCharsetTest.java (original)
> +++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserCharsetTest.java Mon Mar 24 02:14:55 2008
> @@ -46,16 +46,9 @@
>      private static final String TAG = "A1";
>      private static final String ASCII_SEARCH_TERM = "A Search Term";
>      private static final String NON_ASCII_SEARCH_TERM = "\u043A\u0430\u043A \u0414\u0435\u043B\u0430?";
> -    private static final byte[] BYTES_NON_ASCII_SEARCH_TERM = NON_ASCII_SEARCH_TERM.getBytes(UTF8); 
> -    private static final byte[] BYTES_UTF8_NON_ASCII_SEARCH_TERM = add(" {16}\r\n".getBytes(ASCII), BYTES_NON_ASCII_SEARCH_TERM);
> -    private static final byte[] CHARSET = "CHARSET UTF-8 ".getBytes(ASCII);
> -    
> -    private static final byte[] add(byte[] one, byte[] two) {
> -        byte[] results = new byte[one.length + two.length];
> -        System.arraycopy(one, 0, results, 0, one.length);
> -        System.arraycopy(two, 0, results, one.length, two.length);
> -        return results;
> -    }
> +    private static final byte[] BYTES_NON_ASCII_SEARCH_TERM = NioUtils.toBytes(NON_ASCII_SEARCH_TERM, UTF8); 
> +    private static final byte[] BYTES_UTF8_NON_ASCII_SEARCH_TERM = NioUtils.add(NioUtils.toBytes(" {16}\r\n", ASCII), BYTES_NON_ASCII_SEARCH_TERM);
> +    private static final byte[] CHARSET = NioUtils.toBytes("CHARSET UTF-8 ", ASCII);
>      
>      SearchCommandParser parser;
>      Mock mockStatusResponseFactory;
> @@ -151,7 +144,7 @@
>      }
>      
>      private void checkUTF8Valid(byte[] term, final SearchKey key) throws Exception {
> -        ImapRequestLineReader reader = new ImapRequestLineReader(new ByteArrayInputStream(add(add(CHARSET, term), BYTES_UTF8_NON_ASCII_SEARCH_TERM)), 
> +        ImapRequestLineReader reader = new ImapRequestLineReader(new ByteArrayInputStream(NioUtils.add(NioUtils.add(CHARSET, term), BYTES_UTF8_NON_ASCII_SEARCH_TERM)), 
>                  new ByteArrayOutputStream());
>          final SearchKey searchKey = parser.searchKey(reader, null, true);
>          assertEquals(key, searchKey);
> 
> Modified: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserQuotedCharsetTest.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserQuotedCharsetTest.java?rev=640354&r1=640353&r2=640354&view=diff
> ==============================================================================
> --- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserQuotedCharsetTest.java (original)
> +++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserQuotedCharsetTest.java Mon Mar 24 02:14:55 2008
> @@ -58,12 +58,12 @@
>          NON_ASCII_SEARCH_TERM + NON_ASCII_SEARCH_TERM + NON_ASCII_SEARCH_TERM + NON_ASCII_SEARCH_TERM +
>          NON_ASCII_SEARCH_TERM + NON_ASCII_SEARCH_TERM + NON_ASCII_SEARCH_TERM + NON_ASCII_SEARCH_TERM +
>          NON_ASCII_SEARCH_TERM + NON_ASCII_SEARCH_TERM + NON_ASCII_SEARCH_TERM + NON_ASCII_SEARCH_TERM;
> -    private static final byte[] BYTES_LENGTHY_NON_ASCII_SEARCH_TERM = LENGTHY_NON_ASCII_SEARCH_TERM.getBytes(UTF8); 
> -    private static final byte[] BYTES_NON_ASCII_SEARCH_TERM = NON_ASCII_SEARCH_TERM.getBytes(UTF8); 
> -    private static final byte[] BYTES_QUOTED_UTF8_LENGTHY_NON_ASCII_SEARCH_TERM = add(add(" \"".getBytes(ASCII), BYTES_LENGTHY_NON_ASCII_SEARCH_TERM), "\"".getBytes(ASCII));
> -    private static final byte[] BYTES_QUOTED_UTF8_NON_ASCII_SEARCH_TERM = add(add(" \"".getBytes(ASCII), BYTES_NON_ASCII_SEARCH_TERM), "\"".getBytes(ASCII));
> -    private static final byte[] BYTES_UTF8_NON_ASCII_SEARCH_TERM = add(" {16}\r\n".getBytes(ASCII), BYTES_NON_ASCII_SEARCH_TERM);
> -    private static final byte[] CHARSET = "CHARSET UTF-8 ".getBytes(ASCII);
> +    private static final byte[] BYTES_LENGTHY_NON_ASCII_SEARCH_TERM = NioUtils.toBytes(LENGTHY_NON_ASCII_SEARCH_TERM, UTF8); 
> +    private static final byte[] BYTES_NON_ASCII_SEARCH_TERM = NioUtils.toBytes(NON_ASCII_SEARCH_TERM, UTF8); 
> +    private static final byte[] BYTES_QUOTED_UTF8_LENGTHY_NON_ASCII_SEARCH_TERM = add(add(NioUtils.toBytes(" \"", ASCII), BYTES_LENGTHY_NON_ASCII_SEARCH_TERM), NioUtils.toBytes("\"", ASCII));
> +    private static final byte[] BYTES_QUOTED_UTF8_NON_ASCII_SEARCH_TERM = add(add(NioUtils.toBytes(" \"", ASCII), BYTES_NON_ASCII_SEARCH_TERM), NioUtils.toBytes("\"", ASCII));
> +    private static final byte[] BYTES_UTF8_NON_ASCII_SEARCH_TERM = add(NioUtils.toBytes(" {16}\r\n",ASCII), BYTES_NON_ASCII_SEARCH_TERM);
> +    private static final byte[] CHARSET = NioUtils.toBytes("CHARSET UTF-8 ", ASCII);
>      
>      private static final byte[] add(byte[] one, byte[] two) {
>          byte[] results = new byte[one.length + two.length];
> 
> Modified: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserTopLevelAndTest.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserTopLevelAndTest.java?rev=640354&r1=640353&r2=640354&view=diff
> ==============================================================================
> --- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserTopLevelAndTest.java (original)
> +++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/imap4rev1/SearchCommandParserTopLevelAndTest.java Mon Mar 24 02:14:55 2008
> @@ -168,7 +168,7 @@
>          } else {
>              mutations -= 1;
>              for (int i = 0; i < inputs.length; i++) {
> -                StringBuffer nextBuffer = new StringBuffer(buffer);
> +                StringBuffer nextBuffer = new StringBuffer(buffer.toString());
>                  if (nextBuffer.length() > 0) {
>                      nextBuffer.append(' ');
>                  }
> 
> Modified: james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/FetchProcessor.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/FetchProcessor.java?rev=640354&r1=640353&r2=640354&view=diff
> ==============================================================================
> --- james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/FetchProcessor.java (original)
> +++ james/server/trunk/imap-mailbox-processor-function/src/main/java/org/apache/james/imapserver/processor/imap4rev1/FetchProcessor.java Mon Mar 24 02:14:55 2008
> @@ -608,10 +608,7 @@
>          }
>  
>          public int hashCode() {
> -            final int PRIME = 31;
> -            int result = 1;
> -            result = PRIME * result + Arrays.hashCode(positions);
> -            return result;
> +            return positions.length;
>          }
>  
>          public boolean equals(Object obj) {
> 
> Modified: james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/MessageSearches.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/MessageSearches.java?rev=640354&r1=640353&r2=640354&view=diff
> ==============================================================================
> --- james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/MessageSearches.java (original)
> +++ james/server/trunk/torque-mailboxmanager-function/src/main/java/org/apache/james/mailboxmanager/torque/MessageSearches.java Mon Mar 24 02:14:55 2008
> @@ -288,7 +288,7 @@
>              if (headerName.equalsIgnoreCase(name)) {
>                  final String value = header.getValue();
>                  if (value != null) {
> -                    if (value.toUpperCase().contains(text)) {
> +                    if (value.toUpperCase().indexOf(text) > -1) {
>                          result = true;
>                          break;
>                      }
> 
> 
> 
> ---------------------------------------------------------------------
> 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