Skip to content

Commit

Permalink
Missing try/catch on unloadable encoding (patch by headius)
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Oct 24, 2011
1 parent 57f397a commit 53052f0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/org/jruby/RubyString.java
Expand Up @@ -61,6 +61,7 @@
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.UnsupportedCharsetException;
import java.util.Arrays;
import java.util.Locale;

Expand Down Expand Up @@ -7261,8 +7262,11 @@ public IRubyObject encode(ThreadContext context, IRubyObject toEncoding,
}

private static Charset lookupCharsetFor(Ruby runtime, Encoding encoding, String fromName, String toName) {
Charset from = encoding.getCharset();
if (from != null) return from;
Charset from = null;
try {
from = encoding.getCharset();
if (from != null) return from;
} catch (Exception e) {}

try { // We try looking up based on Java's supported charsets...likely missing charset entry in jcodings
from = Charset.forName(encoding.toString());
Expand Down

0 comments on commit 53052f0

Please sign in to comment.