[maven-scm] copy for tag geronimo-javamail_1.4-1.8.1
git-svn-id: https://svn.apache.org/repos/asf/geronimo/javamail/tags/geronimo-javamail_1.4-1.8.1@953650 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/CramMD5Authenticator.java b/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/CramMD5Authenticator.java
index c62deac..91a6425 100644
--- a/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/CramMD5Authenticator.java
+++ b/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/CramMD5Authenticator.java
@@ -19,7 +19,6 @@
package org.apache.geronimo.javamail.authentication;
-import java.nio.charset.Charset;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
diff --git a/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPResponseStream.java b/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPResponseStream.java
index 26c787f..7a2eaf5 100644
--- a/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPResponseStream.java
+++ b/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPResponseStream.java
@@ -20,7 +20,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.nio.charset.Charset;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@@ -131,7 +131,11 @@
// response is in. There are many different untagged formats, some general, some
// specific to particular command types.
if (token.getType() != Token.ATOM) {
- throw new MessagingException("Unknown server response: " + new String(data, Charset.forName("ISO8859-1")));
+ try {
+ throw new MessagingException("Unknown server response: " + new String(data, "ISO8859-1"));
+ } catch (UnsupportedEncodingException e) {
+ throw new MessagingException("Unknown server response: " + new String(data));
+ }
}
String keyword = token.getValue();
@@ -213,7 +217,11 @@
// is 'OK'
return new IMAPTaggedResponse(tag, status, tokenizer.getRemainder(), data);
}
- throw new MessagingException("Unknown server response: " + new String(data, Charset.forName("ISO8859-1")));
+ try {
+ throw new MessagingException("Unknown server response: " + new String(data, "ISO8859-1"));
+ } catch (UnsupportedEncodingException e) {
+ throw new MessagingException("Unknown server response: " + new String(data));
+ }
}
/**
diff --git a/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPResponseTokenizer.java b/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPResponseTokenizer.java
index 7641344..4856f76 100644
--- a/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPResponseTokenizer.java
+++ b/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPResponseTokenizer.java
@@ -19,7 +19,6 @@
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -187,7 +186,11 @@
return "";
}
- return new String(response, pos, response.length - pos, Charset.forName("ISO8859-1"));
+ try {
+ return new String(response, pos, response.length - pos, "ISO8859-1");
+ } catch (UnsupportedEncodingException e) {
+ return null;
+ }
}
@@ -236,14 +239,18 @@
}
}
- // Numeric tokens we store as a different type.
- String value = new String(response, start, pos - start, Charset.forName("ISO8859-1"));
try {
- int intValue = Integer.parseInt(value);
- return new Token(Token.NUMERIC, value);
- } catch (NumberFormatException e) {
+ // Numeric tokens we store as a different type.
+ String value = new String(response, start, pos - start, "ISO8859-1");
+ try {
+ int intValue = Integer.parseInt(value);
+ return new Token(Token.NUMERIC, value);
+ } catch (NumberFormatException e) {
+ }
+ return new Token(Token.ATOM, value);
+ } catch (UnsupportedEncodingException e) {
+ return null;
}
- return new Token(Token.ATOM, value);
}
/**
@@ -376,9 +383,12 @@
* @exception ResponseFormatException
*/
private Token readQuotedString() throws MessagingException {
-
- String value = new String(readQuotedStringData(), Charset.forName("ISO8859-1"));
- return new Token(Token.QUOTEDSTRING, value);
+ try {
+ String value = new String(readQuotedStringData(), "ISO8859-1");
+ return new Token(Token.QUOTEDSTRING, value);
+ } catch (UnsupportedEncodingException e) {
+ return null;
+ }
}
/**
@@ -429,8 +439,12 @@
* @exception ResponseFormatException
*/
protected Token readLiteral() throws MessagingException {
- String value = new String(readLiteralData(), Charset.forName("ISO8859-1"));
- return new Token(Token.LITERAL, value);
+ try {
+ String value = new String(readLiteralData(), "ISO8859-1");
+ return new Token(Token.LITERAL, value);
+ } catch (UnsupportedEncodingException e) {
+ return null;
+ }
}
@@ -481,7 +495,11 @@
* @return A String extracted from the buffer.
*/
protected String substring(int start, int end ) {
- return new String(response, start, end - start, Charset.forName("ISO8859-1"));
+ try {
+ return new String(response, start, end - start, "ISO8859-1");
+ } catch (UnsupportedEncodingException e) {
+ return null;
+ }
}
diff --git a/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/nntp/newsrc/NNTPNewsrcFile.java b/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/nntp/newsrc/NNTPNewsrcFile.java
index 82c91d1..8a8a97c 100644
--- a/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/nntp/newsrc/NNTPNewsrcFile.java
+++ b/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/nntp/newsrc/NNTPNewsrcFile.java
@@ -27,7 +27,6 @@
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
-import java.nio.charset.Charset;
public class NNTPNewsrcFile extends NNTPNewsrc {
// source for the file data
@@ -51,7 +50,7 @@
* @exception IOException
*/
public BufferedReader getInputReader() throws IOException {
- return new BufferedReader(new InputStreamReader(new FileInputStream(source), Charset.forName("ISO8859-1")));
+ return new BufferedReader(new InputStreamReader(new FileInputStream(source), "ISO8859-1"));
}
/**
@@ -62,6 +61,6 @@
*/
public Writer getOutputWriter() throws IOException {
// open this for overwriting
- return new OutputStreamWriter(new FileOutputStream(source, false), Charset.forName("ISO8859-1"));
+ return new OutputStreamWriter(new FileOutputStream(source, false), "ISO8859-1");
}
}
diff --git a/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/pop3/connection/POP3Connection.java b/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/pop3/connection/POP3Connection.java
index 5f1d7c9..8e854b0 100644
--- a/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/pop3/connection/POP3Connection.java
+++ b/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/pop3/connection/POP3Connection.java
@@ -22,7 +22,6 @@
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
-import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
@@ -158,9 +157,11 @@
// The POp3 protocol is inherently a string-based protocol, so we get
// string readers/writers for the connection streams. Note that we explicitly
// set the encoding to ensure that an inappropriate native encoding is not picked up.
- Charset iso88591 = Charset.forName("ISO8859-1");
- reader = new BufferedReader(new InputStreamReader(inputStream, iso88591));
- writer = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(outputStream), iso88591));
+ try {
+ reader = new BufferedReader(new InputStreamReader(inputStream, "ISO8859-1"));
+ writer = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(outputStream), "ISO8859-1"));
+ } catch (UnsupportedEncodingException e) {
+ }
}
protected void getWelcome() throws IOException {
@@ -307,18 +308,20 @@
// it's more efficient to do this a buffer at a time.
// the MIMEInputReader takes care of the byte-stuffing and
// ".\r\n" input terminator for us.
- OutputStreamWriter outWriter = new OutputStreamWriter(out, Charset.forName("ISO8859-1"));
- char buffer[] = new char[500];
try {
- int charsRead = -1;
- while ((charsRead = source.read(buffer)) >= 0) {
- outWriter.write(buffer, 0, charsRead);
+ OutputStreamWriter outWriter = new OutputStreamWriter(out, "ISO8859-1");
+ char buffer[] = new char[500];
+ try {
+ int charsRead = -1;
+ while ((charsRead = source.read(buffer)) >= 0) {
+ outWriter.write(buffer, 0, charsRead);
+ }
+ outWriter.flush();
+ } catch (IOException e) {
+ throw new MessagingException("Error processing a multi-line response", e);
}
- outWriter.flush();
- } catch (IOException e) {
- throw new MessagingException("Error processing a multi-line response", e);
+ } catch (UnsupportedEncodingException e) {
}
-
return out.toByteArray();
}
diff --git a/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java b/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java
index 93525ff..7ec2efb 100644
--- a/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java
+++ b/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java
@@ -33,7 +33,6 @@
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.Socket;
-import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -140,9 +139,11 @@
// The NNTP protocol is inherently a string-based protocol, so we get
// string readers/writers for the connection streams. Note that we explicitly
// set the encoding to ensure that an inappropriate native encoding is not picked up.
- Charset iso88591 = Charset.forName("ISO8859-1");
- reader = new BufferedReader(new InputStreamReader(inputStream, iso88591));
- writer = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(outputStream), iso88591));
+ try {
+ reader = new BufferedReader(new InputStreamReader(inputStream, "ISO8859-1"));
+ writer = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(outputStream), "ISO8859-1"));
+ } catch (UnsupportedEncodingException e) {
+ }
}