From 6eda93228f270520282e399e115b3775b0399db0 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 8 Jan 2021 19:35:15 +0100 Subject: [PATCH] [core] AbstractProvider should also consider TypeVariable aTalk shows the following exception: 2020-12-14 12:11:13.704 7370-30976/org.atalk.android E/AndroidRuntime: FATAL EXCEPTION: AccountManager.loadStoredAccounts Process: org.atalk.android, PID: 7370 java.lang.AssertionError: Element type 'EE' is neither of type Class or ParameterizedType at org.jivesoftware.smack.provider.AbstractProvider.(AbstractProvider.java:46) at org.jivesoftware.smack.provider.Provider.(Provider.java:40) at org.jivesoftware.smack.provider.ExtensionElementProvider.(ExtensionElementProvider.java:29) at org.xmpp.extensions.DefaultExtensionElementProvider.(DefaultExtensionElementProvider.java:43) at org.xmpp.extensions.coin.CoinIQProvider.(CoinIQProvider.java:46) at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderServiceJabberImpl.initialize(ProtocolProviderServiceJabberImpl.java:2091) at net.java.sip.communicator.impl.protocol.jabber.ProtocolProviderFactoryJabberImpl.createService(ProtocolProviderFactoryJabberImpl.java:121) at net.java.sip.communicator.service.protocol.ProtocolProviderFactory.loadAccount(ProtocolProviderFactory.java:934) at net.java.sip.communicator.service.protocol.AccountManager.doLoadStoredAccounts(AccountManager.java:139) at net.java.sip.communicator.service.protocol.AccountManager.loadStoredAccounts(AccountManager.java:294) at net.java.sip.communicator.service.protocol.AccountManager.runInLoadStoredAccountsThread(AccountManager.java:394) at net.java.sip.communicator.service.protocol.AccountManager.access$000(AccountManager.java:36) at net.java.sip.communicator.service.protocol.AccountManager$1.run(AccountManager.java:329) where CoinIQProvider line 46-47 [1] reads private final DefaultExtensionElementProvider urisProvider = new DefaultExtensionElementProvider<>(URIsExtension.class); This fixes SMACK-898. 1: https://github.com/cmeng-git/atalk-android/blob/f61f264312ed9298b96a132c3000dc1031489a74/aTalk/src/main/java/org/xmpp/extensions/coin/CoinIQProvider.java#L47 --- .../jivesoftware/smack/provider/AbstractProvider.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/AbstractProvider.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/AbstractProvider.java index 2897ef820..7749c3783 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/AbstractProvider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/AbstractProvider.java @@ -1,6 +1,6 @@ /** * - * Copyright 2019-2020 Florian Schmaus + * Copyright 2019-2021 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.jivesoftware.smack.provider; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; import org.jivesoftware.smack.packet.Element; @@ -42,9 +43,12 @@ public class AbstractProvider { } else if (elementType instanceof ParameterizedType) { ParameterizedType parameteriezedElementType = (ParameterizedType) elementType; elementClass = (Class) parameteriezedElementType.getRawType(); + } else if (elementType instanceof TypeVariable) { + TypeVariable typeVariableElementType = (TypeVariable) elementType; + elementClass = (Class) typeVariableElementType.getClass(); } else { - throw new AssertionError( - "Element type '" + elementType + "' is neither of type Class or ParameterizedType"); + throw new AssertionError("Element type '" + elementType + "' (" + elementType.getClass() + + ") is neither of type Class, ParameterizedType or TypeVariable"); } }