Index: trunk/modules/luni/src/main/java/java/net/URLEncoder.java =================================================================== --- trunk/modules/luni/src/main/java/java/net/URLEncoder.java (revision 433136) +++ trunk/modules/luni/src/main/java/java/net/URLEncoder.java (working copy) @@ -91,7 +91,7 @@ */ public static String encode(String s, String enc) throws UnsupportedEncodingException { - if (enc == null) { + if (s == null || enc == null) { throw new NullPointerException(); } // check for UnsupportedEncodingException Index: trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLEncoderTest.java =================================================================== --- trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLEncoderTest.java (revision 433136) +++ trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLEncoderTest.java (working copy) @@ -25,7 +25,7 @@ /** * @tests URLEncoder#encode(String, String) */ - public void test_encodeLjava_lang_StringLjava_lang_String() { + public void test_encodeLjava_lang_StringLjava_lang_String() throws Exception { // Regression for HARMONY-24 try { URLEncoder.encode("str","unknown_enc"); @@ -33,5 +33,12 @@ } catch (UnsupportedEncodingException e) { // expected } + //Regression for HARMONY-1233 + try { + URLEncoder.encode(null, "harmony"); + fail("NullPointerException expected"); + } catch (NullPointerException e) { + //expected + } } }