From fc79f6822d3353d8f2e277739e5bf4e0326e2c69 Mon Sep 17 00:00:00 2001 From: Eric Mader Date: Tue, 18 Oct 2005 16:50:15 +0000 Subject: [PATCH] ICU-4883 Handle null return from detect(). X-SVN-Rev: 18698 --- icu4j/src/com/ibm/icu/text/CharsetDetector.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/icu4j/src/com/ibm/icu/text/CharsetDetector.java b/icu4j/src/com/ibm/icu/text/CharsetDetector.java index 7f51e3868f..4205e7296c 100644 --- a/icu4j/src/com/ibm/icu/text/CharsetDetector.java +++ b/icu4j/src/com/ibm/icu/text/CharsetDetector.java @@ -246,7 +246,13 @@ public class CharsetDetector { try { setText(in); - return detect().getReader(); + CharsetMatch match = detect(); + + if (match == null) { + return null; + } + + return match.getReader(); } catch (IOException e) { return null; } @@ -275,7 +281,14 @@ public class CharsetDetector { try { setText(in); - return detect().getString(-1); + + CharsetMatch match = detect(); + + if (match == null) { + return null; + } + + return match.getString(-1); } catch (IOException e) { return null; }