[ https://issues.apache.org/jira/browse/HDFS-14078?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16693052#comment-16693052 ]
Ayush Saxena commented on HDFS-14078: ------------------------------------- Nice Catch [~elek] !!! I guess the Unit Test Failing is due to line number mismatch in the text.IMO we can remove the line number from the assertion text to make it compatible with all other internal codes too. We can even refactor the tests to directly pass the Exception to the AdminHelper.prettifyException() rather than generating it for both UT's Something like this for prettifyExceptionWithNpe() {code:java} String pretty = AdminHelper.prettifyException(new NullPointerException()); Assert.assertTrue(pretty.contains( "NullPointerException at org.apache.hadoop.hdfs.tools.TestAdminHelper.prettifyExceptionWithNpe")); {code} And for prettifyException() {code:java} String pretty = AdminHelper.prettifyException( new IllegalArgumentException("Something is wrong\\nSecond line.")); Assert.assertEquals("IllegalArgumentException: Something is wrong", pretty); {code} > Admin helper fails to prettify NullPointerExceptions > ---------------------------------------------------- > > Key: HDFS-14078 > URL: https://issues.apache.org/jira/browse/HDFS-14078 > Project: Hadoop HDFS > Issue Type: Bug > Reporter: Elek, Marton > Assignee: Elek, Marton > Priority: Major > Attachments: HDFS-14078.001.patch, HDFS-14078.002.patch > > > org.apache.hadoop.hdfs.tools.AdminHelper has a method to prettifyExceptions: > {code} > static String prettifyException(Exception e) { > return e.getClass().getSimpleName() + ": " > + e.getLocalizedMessage().split("\n")[0]; > } > {code} > But if e is a NPE the e.getLocalizedMessage() could be null. In that case NPE > will be thrown and the original error message will be lost. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org