본문 바로가기
프로그래밍 놀이터/안드로이드, Java

[android] Volley URL related issue( bug ) at GingerBread. - java.io.IOException: Malformed ipv6 address:

by 돼지왕 왕돼지 2013. 10. 5.
반응형


 android, Volley URL related issue(bug) at GingerBread.

 - java.io.IOException: Malformed ipv6 address:

 

[android] Volley URL related issue( bug ) at GingerBread.


[En]


If you use Volley network library with GingerBread and the below version devices, you might encounter URLMalformedException with this kind of message.


java.io.IOException: Malformed ipv6 address:


It it known issue about the URL class.


The problem happens when the host part contains port number by the bug.

Therefore, what you have to do is check whether URL's host part contains port number or not, and if it has port number you have to remove it and set it to the port number with other URL constructor.


Refer to the following code.


private URL getURL( String urlStr ) throws MalformedURLException{

URL url = new URL( urlStr );

String host = url.getHost();

int portDelimiterIndex = host.indexOf( ":" );

if ( portDelimiterIndex == -1 ) return url;

String errorRemovedHost = host.substring( 0, portDelimiterIndex );

int port = Integer.parseInt( host.substring( portDelimiterIndex + 1, host.length() ) );

return new URL( url.getProtocol(), errorRemovedHost, port, url.getFile() );

}








[Kr]


만약 Volley network library 를 ginger bread 나 이하 하위버전의 단말에서 사용하고 있다면, 가끔씩 URLMalformedException 에 맞딱뜨렸을 것이다, 다음과 같은 메세지와 함께.


java.io.IOException: Malformed ipv6 address:


이는 URL class 와 관련된 알려진 이슈인데, port number 가 host 쪽에 들어가기 때문이다.

host 쪽에 port number 가 들어갔는지 확인을 하여, port 를 분리시켜 다른 URL constructor 를 이용해서 URL 을 만들어 사용하면 해결된다.


private URL getURL( String urlStr ) throws MalformedURLException{

URL url = new URL( urlStr );

String host = url.getHost();

int portDelimiterIndex = host.indexOf( ":" );

if ( portDelimiterIndex == -1 ) return url;

String errorRemovedHost = host.substring( 0, portDelimiterIndex );

int port = Integer.parseInt( host.substring( portDelimiterIndex + 1, host.length() ) );

return new URL( url.getProtocol(), errorRemovedHost, port, url.getFile() );

}


이놈의 backward compatibility.








반응형

댓글