2017-01-05 4 views
0

우리는 Openfire 4.1.1과 협력 중이며, 이전의 smack 버전 4.1.9와 완벽하게 작동했습니다. 그러나 XEP-0313 (MAP)을 달성하려면 smack 버전 4.2.0-rc1로 업데이트해야합니다. 여기Smack 버전 4.2.0-rc1 XMPPTCPConnectionConfiguration setHostAddress() throws StringIndexOutOfBoundsException

는 "여기 mServiceName가 로컬 IP 주소가"으로 192.168.xx "

InetAddress inetAddress = InetAddress.getByName(mServiceName); 

//InetAddress inetAddress = InetAddress.getLocalHost(); 

XMPPTCPConnectionConfiguration xmpptcpConnectionConfiguration = 
XMPPTCPConnectionConfiguration.builder() 
       .setXmppDomain(mServiceName) 
       .setUsernameAndPassword(mUsername, mPassword) 
       .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled) 
       .setHostAddress(inetAddress) 
       .setPort(5222) 
       .setDebuggerEnabled(true) 
       .setSendPresence(true) 
       .setDebuggerEnabled(true) 
       .setCompressionEnabled(true) 
       .build(); 

XMPPTCPConnectionConfiguration입니다.

그리고 예외

W/System.err: java.lang.StringIndexOutOfBoundsException: length=0; index=-1 
W/System.err:  at java.lang.String.charAt(Native Method) 
W/System.err:  at org.jivesoftware.smack.util.dns.HostAddress.<init>(HostAddress.java:48) 
W/System.err:  at org.jivesoftware.smack.util.dns.HostAddress.<init>(HostAddress.java:62) 
W/System.err:  at org.jivesoftware.smack.AbstractXMPPConnection.populateHostAddresses(AbstractXMP PConnection.java:607) 
W/System.err:  at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPC onnection.java:555) 
W/System.err:  at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:885) 
W/System.err:  at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.ja va:374) 
W/System.err:  at com.example.bosleo.chatapp.ChatConnection.connect(ChatConnection.java:141) 
W/System.err:  at com.example.bosleo.chatapp.ChatConnectionService.initConnection(ChatConnectionS ervice.java:82) 
W/System.err:  at com.example.bosleo.chatapp.ChatConnectionService.access$100(ChatConnectionServi ce.java:20) 
W/System.err:  at com.example.bosleo.chatapp.ChatConnectionService$1.run(ChatConnectionService.ja va:105) 
W/System.err:  at java.lang.Thread.run(Thread.java:818) 

HOSTADDRESS 클래스 생성자에 문의하십시오. 월 그것은 fdqn 값이 ""이기 때문입니다.

public HostAddress(int port, InetAddress hostAddress) { 
    this("", port, Collections.singletonList(hostAddress)); 
} 
public HostAddress(String fqdn, int port, List<InetAddress> inetAddresses) { 

    Objects.requireNonNull(fqdn, "FQDN is null"); 
    if (port < 0 || port > 65535) 
     throw new IllegalArgumentException(
       "Port must be a 16-bit unsiged integer (i.e. between 0-65535. Port was: " + port); 
    if (fqdn.charAt(fqdn.length() - 1) == '.') { 
     this.fqdn = fqdn.substring(0, fqdn.length() - 1); 
    } 
    else { 
     this.fqdn = fqdn; 
    } 
    this.port = port; 
    if (inetAddresses.isEmpty()) { 
     throw new IllegalArgumentException("Must provide at least one InetAddress"); 
    } 
    this.inetAddresses = inetAddresses; 
} 

또는 내가 잘못된 것을하고있는 경우를 대비해 대안이 있습니까? 원본 질문 is here.

답변

1

4.2.0-rc2에서 수정해야하는 버그입니다. 4.2.0-rc2-SNAPSHOT을 놓을 때까지 시도하십시오.

관련 문제