[ 
https://issues.apache.org/jira/browse/HDFS-9896?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15671740#comment-15671740
 ] 

Lucas Lustosa Madureira commented on HDFS-9896:
-----------------------------------------------

Hey there,

I was also able to reproduce this issue on a fedora 21 distribution (with linux 
kernel 3.16.1). Both hadoop versions 2.6.0 and 2.6.5 produced this same error. 
However, version 2.7.3 did not. It is worth mentioning that I tested on a 
pseudo-distributed cluster.
Does that mean the issue is resolved or should the same solution for [branch 
2.7|https://github.com/apache/hadoop/tree/branch-2.7] be applied to [branch 
2.6|https://github.com/apache/hadoop/tree/branch-2.6]?
Bellow is the output I got with and without the error:

{code:title=HADOOP 2.7.3|borderStyle=solid}
Python 2.7.8 (default, Apr 15 2015, 09:26:43)
[GCC 4.9.2 20150212 (Red Hat 4.9.2-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> resp = 
>>> requests.get('http://localhost:50070/webhdfs/v1/tmp/\x00/not_found.txt?op=GETFILESTATUS')
>>> resp.content
'{"RemoteException":{"exception":"FileNotFoundException","javaClassName":"java.io.FileNotFoundException","message":"File
 does not exist: /tmp/\\u0000/not_found.txt"}}'
>> resp.json()
{u'RemoteException': {u'exception': u'FileNotFoundException', u'javaClassName': 
u'java.io.FileNotFoundException', u'message': u'File does not exist: 
/tmp/\x00/not_found.txt'}}
{code}

{code:title=HADOOP 2.6.0 and 2.6.5|borderStyle=solid}
Python 2.7.8 (default, Apr 15 2015, 09:26:43)
[GCC 4.9.2 20150212 (Red Hat 4.9.2-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> resp = 
>>> requests.get('http://localhost:50070/webhdfs/v1/tmp/test/\x00/not_found.txt?op=GETFILESTATUS')
>>> resp.content
'{"RemoteException":{"exception":"FileNotFoundException","javaClassName":"java.io.FileNotFoundException","message":"File
 does not exist: /tmp/test/\x00/not_found.txt"}}'
>>> resp.json()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/requests/models.py", line 833, in json
    self.content.decode(encoding), **kwargs
  File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 382, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Invalid control character at: line 1 column 147 (char 146)

{code}

> WebHDFS API may return invalid JSON
> -----------------------------------
>
>                 Key: HDFS-9896
>                 URL: https://issues.apache.org/jira/browse/HDFS-9896
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: webhdfs
>    Affects Versions: 2.6.0
>         Environment: FreeBSD 10.2
>            Reporter: Alexander Shorin
>            Assignee: John Zhuge
>
> {code}
> >>> import requests
> >>> resp = 
> >>> requests.get('http://server:50000/webhdfs/v1/tmp/test/\x00/not_found.txt?op=GETFILESTATUS')
> >>> resp.content
> '{"RemoteException":{"exception":"FileNotFoundException","javaClassName":"java.io.FileNotFoundException","message":"File
>  does not exist: /tmp/test/\x00/not_found.txt"}}'
> >>> resp.json()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File 
> "/home/sandbox/project/venv/lib/python2.7/site-packages/requests/models.py", 
> line 800, in json
>     self.content.decode(encoding), **kwargs
>   File "/usr/local/lib/python2.7/json/__init__.py", line 338, in loads
>     return _default_decoder.decode(s)
>   File "/usr/local/lib/python2.7/json/decoder.py", line 366, in decode
>     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
>   File "/usr/local/lib/python2.7/json/decoder.py", line 382, in raw_decode
>     obj, end = self.scan_once(s, idx)
> ValueError: Invalid control character at: line 1 column 147 (char 146)
> {code}
> The null byte {{\x00}} should be encoded according JSON rules as {{\u0000}}. 
> It seems like WebHDFS returns path back as is without any processing breaking 
> the content type.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to