Skip to content

Commit

Permalink
Fix InstantiationException
Browse files Browse the repository at this point in the history
  • Loading branch information
theotherp committed Mar 23, 2024
1 parent 2f1479d commit 75c79e3
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions core/src/main/java/org/nzbhydra/indexers/IndexerWebAccess.java
Expand Up @@ -13,7 +13,7 @@
import org.nzbhydra.indexers.exceptions.IndexerProgramErrorException;
import org.nzbhydra.indexers.exceptions.IndexerUnreachableException;
import org.nzbhydra.logging.MdcThreadPoolExecutor;
import org.nzbhydra.mapping.IndexerResponseTypeHolder;
import org.nzbhydra.mapping.nzbindex.NzbIndexRoot;
import org.nzbhydra.springnative.ReflectionMarker;
import org.nzbhydra.web.WebConfiguration;
import org.nzbhydra.webaccess.WebAccess;
Expand Down Expand Up @@ -80,16 +80,10 @@ public <T> T get(URI uri, IndexerConfig indexerConfig, Class responseType) throw
if (responseType == String.class) {
return (T) response;
}
if (responseType != null && IndexerResponseTypeHolder.class.isAssignableFrom(responseType)) {
IndexerResponseTypeHolder responseTypeHolder = (IndexerResponseTypeHolder) responseType.getDeclaredConstructor().newInstance();
if (responseTypeHolder.getType() == IndexerResponseTypeHolder.ResponseType.JSON) {
return (T) Jackson.JSON_MAPPER.readValue(response, responseType);
} else if (responseTypeHolder.getType() == IndexerResponseTypeHolder.ResponseType.XML) {
return unmarshalXml(response);

} else {
throw new RuntimeException("Unexpected responseTypeHolder type " + responseTypeHolder.getType());
}
if (responseType == NzbIndexRoot.class) {
// TODO sist 23.03.2024: Make more generic
return (T) Jackson.JSON_MAPPER.readValue(response, responseType);

}
//Fall back to XML
return unmarshalXml(response);
Expand Down

0 comments on commit 75c79e3

Please sign in to comment.