fix NullPointerException when no selected ALPN available

pull/84/head
Chris Conlon 2022-01-03 11:35:23 -07:00
parent bb97579595
commit c06c714a43
1 changed files with 9 additions and 1 deletions

View File

@ -2840,10 +2840,18 @@ public class WolfSSLSession {
*/
public String getAlpnSelectedString() throws IllegalStateException {
byte[] alpnSelectedBytes = null;
if (this.active == false)
throw new IllegalStateException("Object has been freed");
return new String(getAlpnSelected(), StandardCharsets.UTF_8);
alpnSelectedBytes = getAlpnSelected();
if (alpnSelectedBytes != null) {
return new String(alpnSelectedBytes, StandardCharsets.UTF_8);
} else {
return null;
}
}
/**