[ https://issues.apache.org/jira/browse/HDFS-6169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13962057#comment-13962057 ]
Haohui Mai commented on HDFS-6169: ---------------------------------- The overall control flow is more clear in the following way: {code} public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { String op = getOp(...); try { String path = getPath(...); handleOperation(op, e); } finally { e.getFuture().addListener(ChannelFutureListener.CLOSE); } } {code} Considering the following code in the patch: {code} ... + + private String trimPath(String path, MessageEvent e) { + if (path.startsWith("/webhdfs/v1/")) { + return path.replaceFirst("/webhdfs/v1", ""); + } else { + // invalid path, close the channel + LOG.warn("Path: " + path + " should start with \"/webhdfs/v1/\""); + HttpResponse response = new DefaultHttpResponse( + HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND); + LOG.info("404 method=GET target=" + path); + e.getChannel().write(response).addListener(ChannelFutureListener.CLOSE); + return ""; + } + } {code} 1. How to differentiate the url "/webhdfs/v1?op=LISTSTATUS" and "/wrongurl"? You probably need to return null in the invalid case. 2. It is a bad design to have code of reclaiming resources in different places. I suggest following the control flow described on the top of this comment. > Move the address in WebImageViewer > ---------------------------------- > > Key: HDFS-6169 > URL: https://issues.apache.org/jira/browse/HDFS-6169 > Project: Hadoop HDFS > Issue Type: Sub-task > Components: tools > Affects Versions: 2.5.0 > Reporter: Akira AJISAKA > Assignee: Akira AJISAKA > Attachments: HDFS-6169.2.patch, HDFS-6169.3.patch, HDFS-6169.4.patch, > HDFS-6169.5.patch, HDFS-6169.patch > > > Move the endpoint of WebImageViewer from http://hostname:port/ to > http://hostname:port/webhdfs/v1/ to support {{hdfs dfs -ls}} to > WebImageViewer. -- This message was sent by Atlassian JIRA (v6.2#6252)